本文整理汇总了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)