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


Python Vector.toString方法代码示例

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


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

示例1: __init__

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import toString [as 别名]

#.........这里部分代码省略.........
		self.heading.set((
			self.heading.x,
			self.heading.y * math.cos(angle) - self.heading.z * math.sin(angle),
			self.heading.y * math.sin(angle) + self.heading.z * math.cos(angle)))

	""" Rotation around the y direction """
	def rotY(self, angle):
		if 'turtle' in Conf.DEBUG:
			print "Called: rotY(", angle, ");"
		angle = self.randomize(angle)
		self.heading.set((
			self.heading.x * math.cos(angle) + self.heading.z * math.sin(angle),
			self.heading.y,
			- self.heading.x * math.sin(angle) + self.heading.z * math.cos(angle)))
	""" Reverse rotation around the y direction"""
	def irotY(self, angle):
		if 'turtle' in Conf.DEBUG:
			print "Called: rotY(", angle, ");"
		angle = self.randomize(angle)
		angle = -angle
		self.heading.set((
			self.heading.x * math.cos(angle) + self.heading.z * math.sin(angle),
			self.heading.y,
			- self.heading.x * math.sin(angle) + self.heading.z * math.cos(angle)))

	""" Rotation around the z direction """
	def rotZ(self, angle):
		if 'turtle' in Conf.DEBUG:
			print "Called: rotZ(", angle, ");"
		angle = self.randomize(angle)
		self.heading.set((
			self.heading.x * math.cos(angle) - self.heading.y * math.sin(angle),
			self.heading.x * math.sin(angle) + self.heading.y * math.cos(angle),
			self.heading.z))
	""" Reverse rotation around the z direction"""
	def irotZ(self, angle):
		if 'turtle' in Conf.DEBUG:
			print "Called: rotZ(", angle, ");"
		angle = self.randomize(angle)
		angle = -angle
		self.heading.set((
			self.heading.x * math.cos(angle) - self.heading.y * math.sin(angle),
			self.heading.x * math.sin(angle) + self.heading.y * math.cos(angle),
			self.heading.z))

	def setColor(self, color):
		if 'turtle' in Conf.DEBUG:
			print "Called: setColor(", color, ");"
		#color = self.randomize(color)
		self.color.set(colorsys.rgb_to_hls(color[0], color[1], color[2]))

	def nextColor(self, step):
		if 'turtle' in Conf.DEBUG:
			print "Called: nextColor(", step, ");"
			print "Previous: ", self.color.toString()
		self.color.x += step
		if self.color.x > 1.0:
			self.color.x = self.color.x - 1.0
		if 'turtle' in Conf.DEBUG:
			print "Next: ", self.color.toString()
	""" Close a commend sequence """
	def end(self):
		glBegin(GL_LINES)
		glColor3f(0, 0, 1)
		glVertex3f(self.pos.x, self.pos.y, self.pos.z)
		glVertex3f(float(self.pos.x + self.heading.x), float(self.pos.y + self.heading.y), float(self.pos.z + self.heading.z));
		glEnd()

	""" Draw the turtle path """
	def draw(self):
		if self.vertexBufferChanged or self.vertexPositions is None:
			#print "Vertex buffer changed !"
			#print "Creating numpy array..."
			vertices = np.array(self.vertexBuffer, \
		 					dtype=np.float32)
			#print vertices
			#print "Creating VBO..."
			self.vertexPositions = vbo.VBO(vertices)
			#print "VBO: ", self.vertexPositions.data
			print "Total number of vertex: ", self.vertexBufferLength
			self.vertexBufferChanged = False



		#self.indexPositions.bind()
		self.vertexPositions.bind()
		glEnableClientState(GL_VERTEX_ARRAY)
		glEnableClientState(GL_COLOR_ARRAY)

		glVertexPointer(3, GL_FLOAT, 28, self.vertexPositions )
		glColorPointer(3, GL_FLOAT, 28, self.vertexPositions+12 )
		#glVertexAttribPointer(7, 1, GL_FLOAT, GL_TRUE, 28, self.vertexPositions+24)

		glDrawArrays(self.draw_type, 0, self.vertexBufferLength);
		#glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, None)

		#self.indexPositions.unbind()
		self.vertexPositions.unbind()
		glDisableClientState(GL_VERTEX_ARRAY)
		glDisableClientState(GL_COLOR_ARRAY)
开发者ID:Hiestaa,项目名称:3D-Lsystem,代码行数:104,代码来源:Turtle.py


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