本文整理匯總了Python中utils.Vec.rotate方法的典型用法代碼示例。如果您正苦於以下問題:Python Vec.rotate方法的具體用法?Python Vec.rotate怎麽用?Python Vec.rotate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.Vec
的用法示例。
在下文中一共展示了Vec.rotate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: flag_angles
# 需要導入模塊: from utils import Vec [as 別名]
# 或者: from utils.Vec import rotate [as 別名]
def flag_angles(inst, flag):
"""Check that a instance is pointed in a direction."""
angle = inst["angles", "0 0 0"]
if flag.has_children():
targ_angle = flag["direction", "0 0 0"]
from_dir = flag["from_dir", "0 0 1"]
if from_dir.casefold() in DIRECTIONS:
from_dir = Vec(DIRECTIONS[from_dir.casefold()])
else:
from_dir = Vec.from_str(from_dir, 0, 0, 1)
allow_inverse = utils.conv_bool(flag["allow_inverse", "0"])
else:
targ_angle = flag.value
from_dir = Vec(0, 0, 1)
allow_inverse = False
if angle == targ_angle:
return True # Check for exact match
normal = DIRECTIONS.get(targ_angle.casefold(), None)
if normal is None:
return False # If it's not a special angle,
# so it failed the exact match
angle = Vec.from_str(angle, 0, 0, 0)
inst_normal = from_dir.rotate(angle.x, angle.y, angle.z)
if normal == "WALL":
# Special case - it's not on the floor or ceiling
return not (inst_normal == (0, 0, 1) or inst_normal == (0, 0, -1))
else:
return inst_normal == normal or (allow_inverse and -inst_normal == normal)