本文整理汇总了Python中pyrr.Matrix44.look_at方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix44.look_at方法的具体用法?Python Matrix44.look_at怎么用?Python Matrix44.look_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrr.Matrix44
的用法示例。
在下文中一共展示了Matrix44.look_at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time: float, frame_time: float):
self.ctx.clear(1.0, 1.0, 1.0)
self.ctx.enable(moderngl.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(47.697, -8.147, 24.498),
(0.0, 0.0, 8.0),
(0.0, 0.0, 1.0),
)
rotate = Matrix44.from_z_rotation(np.sin(time) * 0.5 + 0.2)
self.use_texture.value = False
self.light.value = (67.69, -8.14, 52.49)
self.mvp.write((proj * lookat * rotate).astype('f4').tobytes())
self.color.value = (0.67, 0.49, 0.29)
self.objects['ground'].render()
self.color.value = (0.46, 0.67, 0.29)
self.objects['grass'].render()
self.color.value = (1.0, 1.0, 1.0)
self.objects['billboard'].render()
self.color.value = (0.2, 0.2, 0.2)
self.objects['billboard-holder'].render()
self.use_texture.value = True
self.texture.use()
self.objects['billboard-image'].render()
示例2: update
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def update(dt):
ctx.viewport = (0, 0, wnd.width, wnd.height)
ctx.clear(0.9, 0.9, 0.9)
ctx.enable(ModernGL.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, wnd.width / wnd.height, 0.1, 1000.0)
lookat = Matrix44.look_at(
(40.0, 30.0, 20.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
示例3: draw
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def draw(self, *args):
width, height = Window.size
self.ctx.viewport = (0, 0, width, height)
self.ctx.clear(0.9, 0.9, 0.9)
self.ctx.enable(ModernGL.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0)
lookat = Matrix44.look_at(
(40.0, 30.0, 20.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
示例4: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
self.ctx.clear(1.0, 1.0, 1.0)
self.ctx.enable(moderngl.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(40.0, 30.0, 30.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
)
self.mvp.write((proj * lookat).astype('f4').tobytes())
self.vao.render(moderngl.LINES)
示例5: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self):
self.ctx.screen.viewport = self.wnd.viewport
self.ctx.clear(1.0, 1.0, 1.0)
with self.ctx.scope(mgl.DEPTH_TEST):
proj = Matrix44.perspective_projection(45.0, self.wnd.ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(40.0, 30.0, 30.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
)
self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
self.vao.render(mgl.LINES)
示例6: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
angle = time * 0.2
self.ctx.clear(1.0, 1.0, 1.0)
self.ctx.enable(moderngl.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(np.cos(angle), np.sin(angle), 0.8),
(0.0, 0.0, 0.1),
(0.0, 0.0, 1.0),
)
self.mvp.write((proj * lookat).astype('f4').tobytes())
self.vao.render(moderngl.TRIANGLE_STRIP)
示例7: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time: float, frame_time: float):
camera_pos = (np.cos(time) * 300.0, np.sin(time) * 300.0, 120.0)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
camera_pos,
(0.0, 0.0, 50.0),
(0.0, 0.0, 1.0),
)
with self.scope:
self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
self.prog['Eye'] = camera_pos
self.ctx.clear(1.0, 1.0, 1.0)
self.vao.render()
示例8: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
angle = time
self.ctx.clear(1.0, 1.0, 1.0)
camera_pos = (np.cos(angle) * 5.0, np.sin(angle) * 5.0, 2.0)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
camera_pos,
(0.0, 0.0, 0.0),
(0.0, 0.0, 1.0),
)
self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
self.prog['Light'] = camera_pos
self.vao.render()
示例9: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self):
angle = self.wnd.time
self.ctx.screen.viewport = self.wnd.viewport
camera_pos = (np.cos(angle) * 5.0, np.sin(angle) * 5.0, 2.0)
proj = Matrix44.perspective_projection(45.0, self.wnd.ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
camera_pos,
(0.0, 0.0, 0.5),
(0.0, 0.0, 1.0),
)
self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
self.prog['Light'] = camera_pos
self.ctx.replay(self.bytecode)
示例10: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
self.ctx.clear(1.0, 1.0, 1.0)
# self.ctx.enable(mgl.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(47.697, -8.147, 24.498),
(0.0, 0.0, 8.0),
(0.0, 0.0, 1.0),
)
rotate = Matrix44.from_z_rotation(np.sin(time) * 0.5 + 0.2)
w, h = self.texture.size
gw, gh = 16, 16
nx, ny, nz = int(w/gw), int(h/gh), 1
print('=' * 50)
self.compute['time'] = time
GL_WRITE_ONLY = 0x88B9
GL_R32F = 0x822E
self.texture.bind_to_image(0,GL_WRITE_ONLY, GL_R32F)
self.compute.run(nx, ny, nz)
print('-' * 50)
with self.scope:
self.prog['UseTexture'] = False
self.prog['Light'] = (67.69, -8.14, 52.49)
self.prog['Mvp'] = (proj * lookat * rotate).astype('f4').tobytes()
self.prog['Color'] = (0.67, 0.49, 0.29)
self.objects['ground'].render()
self.prog['Color'] = (0.46, 0.67, 0.29)
self.objects['grass'].render()
self.prog['Color'] = (1.0, 1.0, 1.0)
self.objects['billboard'].render()
self.prog['Color'] = (0.2, 0.2, 0.2)
self.objects['billboard-holder'].render()
self.prog['UseTexture'] = True
self.objects['billboard-image'].render()
示例11: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
self.ctx.clear(1.0, 1.0, 1.0)
self.ctx.enable(moderngl.DEPTH_TEST)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
(-85, -180, 140),
(0.0, 0.0, 65.0),
(0.0, 0.0, 1.0),
)
self.light.value = (-140.0, -300.0, 350.0)
self.color.value = (1.0, 1.0, 1.0, 0.25)
self.mvp.write((proj * lookat).astype('f4').tobytes())
self.texture.use()
self.vao.render()
示例12: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
self.ctx.clear(1.0, 1.0, 1.0)
self.bg_texture.use()
self.ctx.enable_only(moderngl.BLEND)
self.canvas_vao.render(moderngl.TRIANGLE_STRIP)
self.ctx.enable_only(moderngl.DEPTH_TEST)
proj = Matrix44.perspective_projection(30.0, self.aspect_ratio, 1.0, 1000.0)
lookat = Matrix44.look_at(
(46.748, -280.619, 154.391),
(-23.844, 2.698, 44.493),
(0.0, 0.0, 1.0),
)
self.mvp.write((proj * lookat).astype('f4').tobytes())
self.light.value = (-143.438, -159.072, 213.268)
self.mug_texture.use()
self.mug_vao.render()
self.ctx.enable_only(moderngl.DEPTH_TEST | moderngl.BLEND)
self.sticker_texture.use()
self.sticker_vao.render(moderngl.TRIANGLE_STRIP)
示例13: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self, time, frame_time):
angle = time * 0.2
self.ctx.clear(1.0, 1.0, 1.0)
self.ctx.enable(moderngl.DEPTH_TEST)
camera_pos = (np.cos(angle) * 5.0, np.sin(angle) * 5.0, 2.0)
proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
camera_pos,
(0.0, 0.0, 0.5),
(0.0, 0.0, 1.0),
)
self.mvp.write((proj * lookat).astype('f4').tobytes())
self.light.value = camera_pos
crate_z = np.sin(self.crate_a * time + self.crate_b) * 0.2
coordinates = np.dstack([self.crate_x, self.crate_y, crate_z])
self.vbo2.write(coordinates.astype('f4').tobytes())
self.vao.render(instances=1024)
示例14: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self):
width, height = self.wnd.size
self.ctx.screen.viewport = self.wnd.viewport
self.ctx.clear(1.0, 1.0, 1.0)
with self.ctx.scope(mgl.DEPTH_TEST):
proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0)
lookat = Matrix44.look_at(
(47.697, -8.147, 24.498),
(0.0, 0.0, 8.0),
(0.0, 0.0, 1.0),
)
rotate = Matrix44.from_z_rotation(np.sin(self.wnd.time) * 0.5 + 0.2)
self.prog['UseTexture'] = False
self.prog['Light'] = (67.69, -8.14, 52.49)
self.prog['Mvp'] = (proj * lookat * rotate).astype('f4').tobytes()
self.prog['Color'] = (0.67, 0.49, 0.29)
self.objects['ground'].render()
self.prog['Color'] = (0.46, 0.67, 0.29)
self.objects['grass'].render()
self.prog['Color'] = (1.0, 1.0, 1.0)
self.objects['billboard'].render()
self.prog['Color'] = (0.2, 0.2, 0.2)
self.objects['billboard-holder'].render()
self.prog['UseTexture'] = True
# self.texture.use()
self.sampler.use()
self.objects['billboard-image'].render()
示例15: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import look_at [as 别名]
def render(self):
angle = self.wnd.time
self.ctx.screen.viewport = self.wnd.viewport
self.ctx.clear(1.0, 1.0, 1.0)
with self.ctx.scope(mgl.DEPTH_TEST):
camera_pos = (np.cos(angle) * 20.0, np.sin(angle) * 20.0, 5.0)
proj = Matrix44.perspective_projection(45.0, self.wnd.ratio, 0.1, 1000.0)
lookat = Matrix44.look_at(
camera_pos,
(0.0, 0.0, 0.5),
(0.0, 0.0, 1.0),
)
self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
self.prog['Light'] = camera_pos
# self.vbo2.write(Matrix33.from_z_rotation(self.wnd.time).astype('f4').tobytes(), offset=24)
self.vbo2.write(b''.join(struct.pack(
'15f',
*car['color'],
*car['pos'],
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
) for car in cars))
self.vao.render(instances=len(cars))
self.vbo2.write(b''.join(struct.pack(
'15f',
0.0, 0.0, 0.0,
*car['pos'],
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.3, 0.6, 0.0,
) for car in cars))
self.vao.render(instances=len(cars))