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


Python GeomNode.removeAllGeoms方法代码示例

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


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

示例1: __init__

# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import removeAllGeoms [as 别名]
class LineMesh:
	def __init__(self, game, color=(1,1,1,1)):
		self.game = game
		self.node = GeomNode("lines")
		self.np = NodePath(self.node)
		self.np.reparentTo(self.game.render)
		self.np.setShaderOff()
		self.format = makeVertexFormat()
		self.vertices = []
		self.lines = []
		self.color = color
		
	def getNbVertices(self):
		return len(self.vertices)
		
	def getNbLines(self):
		return len(self.lines)
	
	def getRandomColor(self):
		return getRandomColor()
		'''
		c1 = random.uniform(0,1)
		c2 = random.uniform(0,1)
		c3 = random.uniform(0,1)
		return (c1, c2, c3, 1)
		'''
		
	nbVertices = property(getNbVertices)
	nbLines = property(getNbLines)
	
	def reset(self):
		self.clearMesh()
		self.vertices = []
		self.lines = []
	
	def clearMesh(self):
		#if self.np:
		#	self.np.remove()
		self.node.removeAllGeoms()
		
		self.vdata = GeomVertexData ('name', self.format, Geom.UHStatic)
		self.vWriter = GeomVertexWriter (self.vdata, 'vertex')
		self.cWriter = GeomVertexWriter (self.vdata, 'color')
		
		self.geom = Geom(self.vdata)
		#self.node = GeomNode("lines")
		
		self.node.addGeom(self.geom)
		
		#self.np = NodePath(self.node)
		#self.np.reparentTo(self.game.render)
		
	def draw(self):
		self.clearMesh()
		#print "vertices : %s" % (self.vertices)
		
		for p in self.vertices:
			self.vWriter.addData3f(p[0], p[1], p[2])
			self.cWriter.addData4f(self.color)
			
		lines = GeomLinestrips (Geom.UHStatic)
		for line in self.lines:
			lines.addVertices(line[0], line[1])
			lines.closePrimitive()
		self.geom.addPrimitive (lines)
		
	def addLineStrip(self, pointList, closed = False):
		nbPts = len(pointList)
		if nbPts < 2:
			return
		
		nbV = self.nbVertices
		
		#for p in pointList:
		#	self.vertices.append(p)
		self.vertices.extend(pointList)
		
		for i in range(nbPts-1):
			self.lines.append((nbV + i, nbV + i + 1))
		if closed:
			self.lines.append((nbV + nbPts - 1, nbV))
	
	def addBox(self, size, pos, rot=0):
		x = size[0] / 2.0
		y = size[1] / 2.0
		z = size[2] / 2.0
		
		#print "drawing lines, x = %s" % (x)
		# base points
		p1 = Point3(-x,-y,-z)
		p2 = Point3(x,-y,-z)
		p3 = Point3(x,y,-z)
		p4 = Point3(-x,y,-z)
		# top points
		p1t = Point3(-x,-y,z)
		p2t = Point3(x,-y,z)
		p3t = Point3(x,y,z)
		p4t = Point3(-x,y,z)
		
		pList = [p1, p2, p3, p4, p1t, p2t, p3t, p4t]
#.........这里部分代码省略.........
开发者ID:arikel,项目名称:PPARPG,代码行数:103,代码来源:meshLine.py


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