本文整理汇总了Python中pi3d.Camera.Camera.get_direction方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.get_direction方法的具体用法?Python Camera.get_direction怎么用?Python Camera.get_direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pi3d.Camera.Camera
的用法示例。
在下文中一共展示了Camera.get_direction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StereoCam
# 需要导入模块: from pi3d.Camera import Camera [as 别名]
# 或者: from pi3d.Camera.Camera import get_direction [as 别名]
#.........这里部分代码省略.........
varying vec2 texcoordout;
void main(void) {{
vec4 texc0 = texture2D(tex0, texcoordout);
vec4 texc1 = texture2D(tex1, texcoordout);
vec2 coord = vec2(gl_FragCoord);
gl_FragColor = mix(texc0, texc1, step(0.5, fract(coord.x / {:f})));
}}
""".format(
interlace * 2.0
),
)
# self.shader = Shader("2d_flat")
self.camera_3d = Camera()
self.forMtrx = np.identity(4, dtype="float32") # initially not rotated
self.position = [0.0, 0.0, 0.0]
self.camera_2d = Camera(is_3d=False)
self.offs = separation / 2.0
self.interlace = interlace
self.textures = []
self.sprites = []
self.tex_list = []
for i in range(2):
self.textures.append(OffScreenTexture(name="stereo"))
ix, iy = self.textures[i].ix, self.textures[i].iy
# two sprites full width but moved so that they are centred on the
# left and right edges. The offset values then move the uv mapping
# so the image is on the right of the left sprite and left of the
# right sprite
self.sprites.append(Sprite(z=20.0, w=ix, h=iy, flip=True))
if interlace <= 0:
self.sprites[i].positionX(-ix / 2.0 + i * ix)
self.sprites[i].set_offset((i * 0.5 - 0.25, 0.0))
else:
self.sprites[i].set_2d_size(w=ix, h=iy)
self.textures[i].blend = True
self.textures[i].mipmap = mipmap
self.tex_list.append(self.textures[i])
opengles.glColorMask(1, 1, 1, 1)
def move_camera(self, position, rot, tilt, roll=0.0, absolute=True):
""" Arguments:
*position*
array [x,y,z]
*rot, tilt, roll*
rotations about y, x, z axis (yes it's not entirely logical for position
to be an array and orientation three values but it's too late to change!)
*absolute*
if set to False then the rotations are treated as relative to the
rotated frame of reference i.e. as if signals from VR headset 3
axis gyro.
"""
self.camera_3d.rotate(tilt, rot, roll)
self.camera_3d.position(position)
self.camera_3d.absolute = absolute
def start_capture(self, side):
""" after calling this method all object.draw()s will rendered
to this texture and not appear on the display.
*side*
Either 0 or 1 to determine stereoscopic view
"""
self.camera_3d.reset()
offs = -self.offs if side == 0 else self.offs
self.camera_3d.offset([offs, 0.0, 0.0])
# self.camera_3d.mtrx = np.dot(self.forMtrx, self.camera_3d.mtrx)
# self.camera_3d.position(self.position)
tex = self.textures[side]
tex._start()
if self.interlace <= 0:
xx = tex.ix / 4.0 # draw the middle only - half width
yy = 0
ww = tex.ix / 2.0
hh = tex.iy
opengles.glEnable(GL_SCISSOR_TEST)
opengles.glScissor(
ctypes.c_int(int(xx)), ctypes.c_int(int(yy)), ctypes.c_int(int(ww)), ctypes.c_int(int(hh))
)
def end_capture(self, side):
""" stop capturing to texture and resume normal rendering to default
"""
self.textures[side]._end()
if self.interlace <= 0:
opengles.glDisable(GL_SCISSOR_TEST)
def draw(self):
""" draw the shape using the saved texture
"""
if self.interlace <= 0:
for i in range(2):
self.sprites[i].draw(self.shader, [self.tex_list[i]], 0.0, 0.0, self.camera_2d)
else:
self.sprites[0].draw(self.shader, self.tex_list, 0.0, 0.0, self.camera_2d)
def get_direction(self):
return self.camera_3d.get_direction()