예제 #1
0
    def __init__(self,
                 position,
                 width,
                 height,
                 color=(0, 255, 0),
                 orientation=None,
                 shader_manager=None):
        '''TODO:
            - Add set plane normal
        '''
        plane_mesh, plane_faces, _ = geometry.create_plane(
            width,
            height,
            width_segments=int(width * 5),
            height_segments=int(height * 5),
        )

        plane_buffer = np.zeros(len(plane_mesh['position']),
                                dtype=[('a_position', np.float32, 3),
                                       ('a_normal', np.float32, 3)])
        plane_buffer['a_position'] = plane_mesh['position']
        plane_buffer['a_normal'] = plane_mesh['normal']
        super(self.__class__, self).__init__(gloo.VertexBuffer(plane_buffer),
                                             faces=plane_faces,
                                             position=position,
                                             color=color)

        self.set_debug()
        shader_manager.register_lighting_shader(self)
        self.program['u_shininess'] = 16.0
        self.program['u_specular_color'] = self.color[:3]
예제 #2
0
파일: world.py 프로젝트: DSsoto/Sub8
    def __init__(self, position, width, height, color=(0, 255, 0), orientation=None, shader_manager=None):
        '''TODO:
            - Add set plane normal
        '''
        plane_mesh, plane_faces, _ = geometry.create_plane(
            width, height,
            width_segments=int(width * 5),
            height_segments=int(height * 5),
        )

        plane_buffer = np.zeros(
            len(plane_mesh['position']),
            dtype=[
                ('a_position', np.float32, 3),
                ('a_normal', np.float32, 3)
            ]
        )
        plane_buffer['a_position'] = plane_mesh['position']
        plane_buffer['a_normal'] = plane_mesh['normal']
        super(self.__class__, self).__init__(gloo.VertexBuffer(plane_buffer), faces=plane_faces, position=position,
                                             color=color)

        self.set_debug()
        shader_manager.register_lighting_shader(self)
        self.program['u_shininess'] = 16.0
        self.program['u_specular_color'] = self.color[:3]
예제 #3
0
def test_plane():
    """Test plane function"""
    vertices, filled, outline = create_plane()
    assert_array_equal(np.arange(len(vertices)), np.unique(filled))
    assert_array_equal(np.arange(len(vertices)), np.unique(outline))
예제 #4
0
파일: plane.py 프로젝트: astrofrog/vispy
"""
Simple demonstration of the plane geometry.
"""

import sys

from vispy import scene
from vispy import geometry

canvas = scene.SceneCanvas(keys='interactive', size=(800, 600), show=True)

view = canvas.central_widget.add_view()

vertices, faces, outline = geometry.create_plane(width=2, height=4,
                                                 width_segments=4,
                                                 height_segments=8,
                                                 direction='+y')

plane = scene.visuals.Plane(width=2, height=4, width_segments=4,
                            height_segments=8, direction='+y',
                            vertex_colors=vertices['color'],
                            edge_color='k',
                            parent=view.scene)

camera = scene.cameras.TurntableCamera(fov=45, azimuth=-45, parent=view.scene)
view.camera = camera

if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()
예제 #5
0
"""
Simple demonstration of the plane geometry.
"""

import sys

from vispy import scene
from vispy import geometry

canvas = scene.SceneCanvas(keys='interactive', size=(800, 600), show=True)

view = canvas.central_widget.add_view()

vertices, faces, outline = geometry.create_plane(width=2,
                                                 height=4,
                                                 width_segments=4,
                                                 height_segments=8,
                                                 direction='+y')

plane = scene.visuals.Plane(width=2,
                            height=4,
                            width_segments=4,
                            height_segments=8,
                            direction='+y',
                            vertex_colors=vertices['color'],
                            edge_color='k',
                            parent=view.scene)

camera = scene.cameras.TurntableCamera(fov=45, azimuth=-45, parent=view.scene)
view.camera = camera