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


Python Camera.point_at方法代码示例

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


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

示例1: ShadowCaster

# 需要导入模块: from pi3d.Camera import Camera [as 别名]
# 或者: from pi3d.Camera.Camera import point_at [as 别名]
class ShadowCaster(OffScreenTexture):
  """For creating a depth-of-field blurring effect on selected objects"""
  def __init__(self, position, light, scale=10.0):
    """ calls Texture.__init__ but doesn't need to set file name as
    texture generated from the framebuffer
    """
    super(ShadowCaster, self).__init__("shadow_caster")

    self.LIGHT_CAM = Camera(is_3d=False, scale=scale)
    l_p = light.lightpos
    l_len = (l_p[0]**2 + l_p[1]**2 + l_p[2]**2)**0.5
    self.OFFSET = [200.0 * i / l_len for i in l_p]
    self.LIGHT_CAM.position([position[i] - o for i, o in enumerate(self.OFFSET)])
    self.tilt, self.rot = self.LIGHT_CAM.point_at(position)
    self.cast_shader = Shader("shadowcast")


  def move_light(self, position):
    self.LIGHT_CAM.reset()
    self.LIGHT_CAM.rotate(self.tilt, self.rot, 0)
    self.LIGHT_CAM.position([position[i] - o for i, o in enumerate(self.OFFSET)])


  def start_cast(self, position=None):
    if position is not None:
      self.move_light(position)
    super(ShadowCaster, self)._start()


  def cast_shadow(self, shape):
    shape.draw(shader=self.cast_shader, light_camera=self.LIGHT_CAM)


  def end_cast(self):
    super(ShadowCaster, self)._end()

    
  def draw_shadow(self):
    self.emap.draw(shader=self.dshader)


  def draw_tree(self, tree, shader):
    tree.draw(shader, [self])
开发者ID:Clever-Boy,项目名称:pi3d,代码行数:45,代码来源:ShadowCaster.py


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