本文整理汇总了Python中vispy.gloo.set_state函数的典型用法代码示例。如果您正苦于以下问题:Python set_state函数的具体用法?Python set_state怎么用?Python set_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_state函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: draw_distortion
def draw_distortion(self, *Contexts):
'''Distorter.draw(list_of_drawables)
Draw the drawables to the right and left-eye render buffers,
then apply the distortion and display these buffers to the screen
TODO:
How can we globally handle view?
Should we even bother trying to find the 'right' way to do this?
'''
gloo.set_clear_color('black')
gloo.set_state(depth_test=True)
with self.left_eye:
gloo.clear(color=True, depth=True)
for context in Contexts:
context.translate(0, self.IPD / 2, 0)
context.set_projection(self.L_projection)
context.draw()
with self.right_eye:
gloo.clear(color=True, depth=True)
for context in Contexts:
context.translate(0, -self.IPD / 2, 0)
context.set_projection(self.R_projection)
context.draw()
gloo.clear(color=True, depth=True)
self.left_eye_program.draw('triangles', self.left_eye_indices)
self.right_eye_program.draw('triangles', self.right_eye_indices)
开发者ID:jpanikulam,项目名称:visar,代码行数:28,代码来源:make_distortion.py
示例2: __init__
def __init__(self):
app.Canvas.__init__(self, keys='interactive', size=(800, 600))
self.vertices, self.filled, self.outline = cube()
self.filled_buf = gloo.IndexBuffer(self.filled)
self.outline_buf = gloo.IndexBuffer(self.outline)
self.program = gloo.Program(vert, frag)
self.program.bind(gloo.VertexBuffer(self.vertices))
self.view = translate((0, 0, -5))
self.model = np.eye(4, dtype=np.float32)
gloo.set_viewport(0, 0, self.physical_size[0], self.physical_size[1])
self.projection = perspective(45.0, self.size[0] /
float(self.size[1]), 2.0, 10.0)
self.program['u_projection'] = self.projection
self.program['u_model'] = self.model
self.program['u_view'] = self.view
self.theta = 0
self.phi = 0
gloo.set_clear_color('white')
gloo.set_state('opaque')
gloo.set_polygon_offset(1, 1)
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
self.show()
开发者ID:Calvarez20,项目名称:vispy,代码行数:32,代码来源:rotate_cube.py
示例3: __init__
def __init__(self):
app.Canvas.__init__(self, size=(512, 512), title='Rotating cube',
keys='interactive')
self.timer = app.Timer('auto', self.on_timer)
# Build cube data
V, I, outline = create_cube()
vertices = VertexBuffer(V)
self.faces = IndexBuffer(I)
self.outline = IndexBuffer(outline)
# Build program
# --------------------------------------
self.program = Program(vertex, fragment)
self.program.bind(vertices)
# Build view, model, projection & normal
# --------------------------------------
view = translate((0, 0, -5))
model = np.eye(4, dtype=np.float32)
self.program['u_model'] = model
self.program['u_view'] = view
self.phi, self.theta = 0, 0
self.activate_zoom()
# OpenGL initialization
# --------------------------------------
gloo.set_state(clear_color=(0.30, 0.30, 0.35, 1.00), depth_test=True,
polygon_offset=(1, 1), line_width=0.75,
blend_func=('src_alpha', 'one_minus_src_alpha'))
self.timer.start()
self.show()
开发者ID:Eric89GXL,项目名称:vispy,代码行数:35,代码来源:outlined_cube.py
示例4: __init__
def __init__(self):
app.Canvas.__init__(self, size=(512, 512), title='Colored cube',
keys='interactive')
# Build cube data
V, I, _ = create_cube()
vertices = VertexBuffer(V)
self.indices = IndexBuffer(I)
# Build program
self.program = Program(vertex, fragment)
self.program.bind(vertices)
# Build view, model, projection & normal
view = translate((0, 0, -5))
model = np.eye(4, dtype=np.float32)
self.program['model'] = model
self.program['view'] = view
self.phi, self.theta = 0, 0
gloo.set_state(clear_color=(0.30, 0.30, 0.35, 1.00), depth_test=True)
self.activate_zoom()
self.timer = app.Timer('auto', self.on_timer, start=True)
self.show()
开发者ID:Lx37,项目名称:vispy,代码行数:26,代码来源:colored_cube.py
示例5: on_initialize
def on_initialize(self, event):
# Build cube data
V, F, O = create_cube()
vertices = VertexBuffer(V)
self.faces = IndexBuffer(F)
self.outline = IndexBuffer(O)
# Build view, model, projection & normal
# --------------------------------------
self.view = np.eye(4, dtype=np.float32)
model = np.eye(4, dtype=np.float32)
translate(self.view, 0, 0, -5)
normal = np.array(np.matrix(np.dot(self.view, model)).I.T)
# Build program
# --------------------------------------
self.program = Program(vertex, fragment)
self.program.bind(vertices)
self.program["u_light_position"] = 2, 2, 2
self.program["u_light_intensity"] = 1, 1, 1
self.program["u_model"] = model
self.program["u_view"] = self.view
self.program["u_normal"] = normal
self.phi, self.theta = 0, 0
# OpenGL initalization
# --------------------------------------
gloo.set_state(clear_color=(0.30, 0.30, 0.35, 1.00), depth_test=True,
polygon_offset=(1, 1),
blend_func=('src_alpha', 'one_minus_src_alpha'),
line_width=0.75)
self.timer.start()
开发者ID:gbaty,项目名称:vispy,代码行数:32,代码来源:lighted_cube.py
示例6: __init__
def __init__(self,controller, **kwargs):
app.Canvas.__init__(self, **kwargs)
self._controller = controller
self.geometry = 0, 0, 400, 400
self.program = gloo.Program("shaders/raytracingalgo.vertexshader", "shaders/raytracingalgo.fragmentshader")
self.program['a_position'] = [(-1., -1.), (-1., +1.),(+1., -1.), (+1., +1.)]
self.program['sphere_position_0'] = (.75, .1, 1.)
self.program['sphere_radius_0'] = .6
self.program['sphere_color_0'] = (1., 1., 1.)
self.program['sphere_position_1'] = (-.75, .1, 2.25)
self.program['sphere_radius_1'] = .6
self.program['sphere_color_1'] = (1., 1., 1.)
self.program['plane_position'] = (0., -.5, 0.)
self.program['plane_normal'] = (0., 1., 0.)
self.program['light_intensity'] = 1.
self.program['light_specular'] = (1., 50.)
self.program['light_position'] = (5., 5., -10.)
self.program['light_color'] = (1., 1., 1.)
self.program['ambient'] = .05
self.program['O'] = (0., 0., -1.)
gloo.set_clear_color((1, 1, 1, 1))
gloo.set_state(depth_test=True)
#self.program.draw('triangle_strip')
#self.active = True
self._timer = app.Timer('auto', connect=self.timedUpdate, start=True)
self._fps = 1
self._timerfps = 24
self._softFPS = []
开发者ID:PierreGe,项目名称:ba3-project,代码行数:34,代码来源:RayTracingWidget.py
示例7: __init__
def __init__(self):
app.Canvas.__init__(self, size=(512, 512), title='Textured cube',
keys='interactive')
self.timer = app.Timer('auto', self.on_timer)
# Build cube data
V, I, _ = create_cube()
vertices = VertexBuffer(V)
self.indices = IndexBuffer(I)
# Build program
self.program = Program(vertex, fragment)
self.program.bind(vertices)
# Build view, model, projection & normal
view = np.eye(4, dtype=np.float32)
model = np.eye(4, dtype=np.float32)
translate(view, 0, 0, -5)
self.program['model'] = model
self.program['view'] = view
self.program['texture'] = checkerboard()
self.phi, self.theta = 0, 0
# OpenGL initalization
gloo.set_state(clear_color=(0.30, 0.30, 0.35, 1.00), depth_test=True)
self.timer.start()
开发者ID:almarklein,项目名称:vispy,代码行数:27,代码来源:textured_cube.py
示例8: on_draw
def on_draw(self, event):
gloo.clear()
# Filled cube
gloo.set_state(blend=False, depth_test=True, polygon_offset_fill=True)
self.program.draw('triangles', self.filled_buf)
开发者ID:jay3sh,项目名称:vispy,代码行数:7,代码来源:objloader.py
示例9: __init__
def __init__(self, svbrdf, mesh, camera, size):
super().__init__(size, 0, 1000, camera, show=True)
gloo.set_state(depth_test=True)
gloo.set_viewport(0, 0, *self.size)
self.lights = [
Light((20, 30, 100), 2000),
Light((20, 30, -100), 2000),
Light((0, 100, 10), 2000),
]
vertex_positions = mesh.expand_face_vertices()
vertex_normals = mesh.expand_face_normals()
vertex_tangents, vertex_bitangents = mesh.expand_tangents()
vertex_uvs = mesh.expand_face_uvs()
material = SVBRDFMaterial(svbrdf)
self.renderables = [Renderable(material, {
'a_position': vertex_positions,
'a_normal': vertex_normals,
'a_tangent': vertex_tangents,
'a_bitangent': vertex_bitangents,
'a_uv': vertex_uvs,
}, len(self.lights))]
开发者ID:void42,项目名称:svbrdf-renderer,代码行数:25,代码来源:main.py
示例10: __init__
def __init__(self, *args, **kwargs):
self.exit = kwargs.pop('exit', False)
self.inputs_path = kwargs.pop('inputs_path', None)
super(StillCanvas, self).__init__(*args, **kwargs)
gloo.set_state(clear_color='black', blend=True, blend_func=('src_alpha', 'one_minus_src_alpha'))
self.inputs = None
if self.inputs_path is not None:
self.input_manager = FileStoredInput(self.inputs_path)
self.time = self.input_manager.stored_time
definition = Definitions[self.input_manager.stored_definition_name]
else:
self.input_manager = RandomInput()
self.time = float(random.randint(0, 345212312))
definition = Definitions[random.choice(Definitions.keys())]
self.fractal = FractalProgram(definition, mask=False)
self.apply_zoom()
self._timer = app.Timer(1.0 / 5, connect=self.update, start=True)
if self.exit:
app.Timer(1, connect=self.write_and_exit, start=True, iterations=1)
# self.update(None)
# self.update(None)
self.show()
开发者ID:airhorns,项目名称:body-fractals,代码行数:26,代码来源:still_render.py
示例11: __init__
def __init__(self):
app.Canvas.__init__(self, keys='interactive')
self.size = 800, 600
self.vertices, self.filled, self.outline = cube()
self.filled_buf = gloo.IndexBuffer(self.filled)
self.outline_buf = gloo.IndexBuffer(self.outline)
self.program = gloo.Program(vert, frag)
self.program.bind(gloo.VertexBuffer(self.vertices))
self.view = np.eye(4, dtype=np.float32)
self.model = np.eye(4, dtype=np.float32)
self.projection = np.eye(4, dtype=np.float32)
translate(self.view, 0, 0, -5)
self.program['u_model'] = self.model
self.program['u_view'] = self.view
self.theta = 0
self.phi = 0
gloo.set_clear_color('white')
gloo.set_state('opaque')
gloo.set_polygon_offset(1, 1)
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:27,代码来源:rotate_cube.py
示例12: __init__
def __init__(self, atoms, radius=6.):
app.Canvas.__init__(self, title='Molecular viewer', keys='interactive', size=(1200, 800))
self.ps = self.pixel_scale
self.zoom = .5/numpy.amax(numpy.linalg.norm(atoms['zyx'], axis=1))
self.program = gloo.Program(vertex, fragment)
self.view = scale(self.zoom*numpy.ones(3))
self.model = numpy.eye(4, dtype=numpy.float32)
self.projection = numpy.eye(4, dtype=numpy.float32)
data = numpy.zeros(atoms.size, [('a_position', numpy.float32, 3),
('a_color', numpy.float32, 4),
('a_radius', numpy.float32, 1)])
data['a_position'] = atoms['zyx']
data['a_color'] = 1,0,0,1
data['a_color'][atoms['Z']==16] = 1,1,0,1
data['a_color'][atoms['Z']==74] = 0,.5,1,1
data['a_radius'] = atoms['Z']**(1/3)*radius/self.zoom
self.program.bind(gloo.VertexBuffer(data))
self.program['u_zoom'] = self.zoom
self.program['u_model'] = self.model
self.program['u_view'] = self.view
self.program['u_light_position'] = 0., 0., 2.
self.program['u_light_spec_position'] = -5., 5., -5.
self.apply_zoom()
self.program['u_model'] = self.model
self.program['u_view'] = self.view
gloo.set_state(depth_test=True, clear_color='white')
self.show()
开发者ID:JKrehl,项目名称:Electrons,代码行数:35,代码来源:AtomsViewer.py
示例13: __init__
def __init__(self, *args, **kwargs):
self.fake_inputs = kwargs.pop('fake_inputs', False)
self.draw_bones = kwargs.pop('draw_bones', False)
self.kiosk_interval = kwargs.pop('kiosk_interval', 0)
self.start_definition = kwargs.pop('start_definition', 0)
self.start_input = kwargs.pop('start_input', 0)
self.show_mask = kwargs.pop('mask', False)
super(MainCanvas, self).__init__(*args, **kwargs)
gloo.set_state(clear_color='black', blend=True, blend_func=('src_alpha', 'one_minus_src_alpha'))
self.skeleton_bones = SkeletonBonesProgram()
self.mask = MaskProgram()
self.inputs = None
self.input_manager = None
self._starttime = time.time()
self.definition_position = self.start_definition
self.input_position = self.start_input
self.rotate()
if self.kiosk_interval > 0:
self.kiosk_timer = app.Timer(self.kiosk_interval, connect=self.rotate, start=True)
self._timer = app.Timer('auto', connect=self.update, start=True)
self.show()
开发者ID:airhorns,项目名称:body-fractals,代码行数:26,代码来源:main.py
示例14: __init__
def __init__(self):
app.Canvas.__init__(self, keys='interactive')
self.size = 800, 800
self.title = "D'oh ! A big donut"
self.program = gloo.Program(vert, frag)
self.view = np.eye(4, dtype=np.float32)
self.model = np.eye(4, dtype=np.float32)
self.projection = np.eye(4, dtype=np.float32)
self.translate = 5
translate(self.view, 0, 0, -self.translate)
self.program.bind(gloo.VertexBuffer(data))
self.program['u_linewidth'] = u_linewidth
self.program['u_antialias'] = u_antialias
self.program['u_model'] = self.model
self.program['u_view'] = self.view
self.program['u_size'] = 5 / self.translate
self.theta = 0
self.phi = 0
self.clock = 0
self.stop_rotation = False
gloo.set_state('translucent', clear_color='white')
self.program['u_clock'] = 0.0
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:28,代码来源:donut.py
示例15: __init__
def __init__(self):
app.Canvas.__init__(self, size=(512, 512),
keys='interactive')
self.image = Program(image_vertex, image_fragment, 4)
self.image['position'] = (-1, -1), (-1, +1), (+1, -1), (+1, +1)
self.image['texcoord'] = (0, 0), (0, +1), (+1, 0), (+1, +1)
self.image['vmin'] = +0.0
self.image['vmax'] = +1.0
self.image['cmap'] = 0 # Colormap index to use
self.image['colormaps'] = colormaps
self.image['n_colormaps'] = colormaps.shape[0]
self.image['image'] = I.astype('float32')
self.image['image'].interpolation = 'linear'
set_viewport(0, 0, *self.physical_size)
self.lines = Program(lines_vertex, lines_fragment)
self.lines["position"] = np.zeros((4+4+514+514, 2), np.float32)
color = np.zeros((4+4+514+514, 4), np.float32)
color[1:1+2, 3] = 0.25
color[5:5+2, 3] = 0.25
color[9:9+512, 3] = 0.5
color[523:523+512, 3] = 0.5
self.lines["color"] = color
set_state(clear_color='white', blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha'))
self.show()
开发者ID:Calvarez20,项目名称:vispy,代码行数:30,代码来源:imshow_cuts.py
示例16: on_initialize
def on_initialize(self, event):
self.rho = 0.0
# Build cube data
# --------------------------------------
self.checker = Program(cube_vertex, cube_fragment)
self.checker['texture'] = checkerboard()
self.checker['position'] = [(-1, -1), (-1, +1), (+1, -1), (+1, +1)]
self.checker['texcoord'] = [(0, 0), (0, 1), (1, 0), (1, 1)]
# sheet, indices = make_sheet((960, 1080))
# sheet_buffer = VertexBuffer(sheet)
left_eye = Texture2D((960, 1080, 3), interpolation='linear')
self.left_eye_buffer = FrameBuffer(left_eye, RenderBuffer((960, 1080)))
# Build program
# --------------------------------------
self.view = np.eye(4, dtype=np.float32)
self.program = Program(vertex, fragment)
distortion_buffer = VertexBuffer(make_distortion())
self.program.bind(distortion_buffer)
self.program['rotation'] = self.view
self.program['texture'] = left_eye
# OpenGL and Timer initalization
# --------------------------------------
set_state(clear_color=(.3, .3, .35, 1), depth_test=True)
self.timer = app.Timer('auto', connect=self.on_timer, start=True)
self._set_projection(self.size)
开发者ID:jpanikulam,项目名称:visar,代码行数:28,代码来源:visualize_mesh.py
示例17: __init__
def __init__(self):
app.Canvas.__init__(self, title='Rain [Move mouse]',
size=(512, 512), keys='interactive')
# Build data
# --------------------------------------
n = 500
self.data = np.zeros(n, [('a_position', np.float32, 2),
('a_fg_color', np.float32, 4),
('a_size', np.float32, 1)])
self.index = 0
self.program = Program(vertex, fragment)
self.vdata = VertexBuffer(self.data)
self.program.bind(self.vdata)
self.program['u_antialias'] = 1.00
self.program['u_linewidth'] = 1.00
self.program['u_model'] = np.eye(4, dtype=np.float32)
self.program['u_view'] = np.eye(4, dtype=np.float32)
self.activate_zoom()
gloo.set_clear_color('white')
gloo.set_state(blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha'))
self.timer = app.Timer('auto', self.on_timer, start=True)
self.show()
开发者ID:Eric89GXL,项目名称:vispy,代码行数:27,代码来源:rain.py
示例18: __init__
def __init__(self, **kwargs):
# Initialize the canvas for real
app.Canvas.__init__(self, keys='interactive', **kwargs)
self.size = 512, 512
self.position = 50, 50
self.vbo = gloo.VertexBuffer(data)
self.index = gloo.IndexBuffer(edges)
self.view = np.eye(4, dtype=np.float32)
self.model = np.eye(4, dtype=np.float32)
self.projection = np.eye(4, dtype=np.float32)
self.program = gloo.Program(vert, frag)
self.program.bind(self.vbo)
self.program['u_size'] = 1
self.program['u_antialias'] = u_antialias
self.program['u_model'] = self.model
self.program['u_view'] = self.view
self.program['u_projection'] = self.projection
self.program_e = gloo.Program(vs, fs)
self.program_e.bind(self.vbo)
set_state(clear_color='white', depth_test=False, blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha'))
开发者ID:almarklein,项目名称:vispy,代码行数:25,代码来源:graph.py
示例19: __init__
def __init__(self, time_acceleration=1.0, show_window=True, physics_dt=(1 / 30.)):
app.Canvas.__init__(self, keys='interactive', size=(800, 800))
rospy.on_shutdown(self.end)
# How much sim time should pass for each real world second
self.dt_per_second = time_acceleration
# How much physics time should pass for each physics iteration
self.physics_dt = physics_dt
print 'Time per second', self.dt_per_second, 'gaptime:', self.physics_dt / self.dt_per_second
self.size = (800, 800)
self.translate = np.array([0.0, 0.0, 0.0])
self.rotate = np.array([0.0, 0.0, 0.0])
gloo.set_state(depth_test=True, blend=True, preset='translucent')
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
self.physics_timer = app.Timer(self.physics_dt / self.dt_per_second, connect=self.step_physics, start=True)
self.clock = 0.0
self.view = np.eye(4)
# Do any visualization?
# TODO: Can we do any rendering at all like this?
if show_window:
self.show()
self.keypress_pub = rospy.Publisher('sim/keypress', String, queue_size=10)
开发者ID:APCarney,项目名称:Sub8,代码行数:27,代码来源:visualization.py
示例20: __init__
def __init__(self):
app.Canvas.__init__(self, position=(50, 50), keys='interactive')
self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
self.program['a_position'] = gloo.VertexBuffer(v_position)
self.program['a_color'] = gloo.VertexBuffer(v_color)
self.program['a_size'] = gloo.VertexBuffer(v_size)
self.program['u_pan'] = (0., 0.)
self.program['u_scale'] = (1., 1.)
self.program['u_vec1'] = (1., 0., 0., 0.)
self.program['u_vec2'] = (0., 1., 0., 0.)
# Circulant matrix.
circ = np.diagflat(np.ones(ndim-1), 1)
circ[-1, 0] = -1 if ndim % 2 == 0 else 1
self.logcirc = logm(circ)
# We will solve the equation dX/dt = log(circ) * X in real time
# to compute the matrix exponential expm(t*log(circ)).
self.mat = np.eye(ndim)
self.dt = .001
gloo.set_state(clear_color=(1, 1, 1, 1), blend=True,
blend_func=('src_alpha', 'one_minus_src_alpha'))
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:26,代码来源:ndscatter.py
注:本文中的vispy.gloo.set_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论