本文整理汇总了Python中Vector.Vector.getDirectionVectors方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.getDirectionVectors方法的具体用法?Python Vector.getDirectionVectors怎么用?Python Vector.getDirectionVectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector.Vector
的用法示例。
在下文中一共展示了Vector.getDirectionVectors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import getDirectionVectors [as 别名]
class Camera:
def __init__(self, state):
self.position = Vector(0, 0, 100)
self.orientation = Vector(0, 0, 0)
self.frame = 0
self.dirty = False
self.directionVectors = self.orientation.getDirectionVectors()
self.state = state
self.read_config()
def read_config(self):
self.sensitivity = self.state.config['camera']['sensitivity']
self.z_speed = self.state.config['camera']['z_speed'] * self.sensitivity
self.movement_speed = self.state.config['camera']['movement_speed'] * self.sensitivity
self.yaw_speed = self.state.config['camera']['sensitivity_3d']['yaw'] * self.sensitivity
self.pitch_speed = self.state.config['camera']['sensitivity_3d']['pitch'] * self.sensitivity
def up(self):
self.position.z -= self.z_speed
def down(self):
self.position.z += self.z_speed
def forward(self):
dir = self.getDirectionVectors()
v = dir.forward.scale(self.movement_speed, True)
v.z = 0
self.position -= v
def back(self):
dir = self.getDirectionVectors()
v = dir.forward.scale(self.movement_speed, True)
v.z = 0
self.position += v
def left(self):
dir = self.getDirectionVectors()
self.position += dir.right.scale(self.movement_speed, True)
def right(self):
dir = self.getDirectionVectors()
self.position -= dir.right.scale(self.movement_speed, True)
def rotate_yaw(self, distance):
self.orientation.y -= distance * self.yaw_speed
if self.orientation.y < 0:
self.orientation.y += 360
if self.orientation.y > 360:
self.orientation.y -= 360
self.dirty = True
def rotate_pitch(self, distance):
self.dirty = True
self.orientation.x += distance * self.pitch_speed
self.orientation.x = limit(self.orientation.x, -90, 90)
def getDirectionVectors(self):
if self.dirty:
self.directionVectors = self.orientation.getDirectionVectors()
self.dirty = False
return self.directionVectors