Beispiel #1
0
    def setUp(self):
        '''
        Create a scene with a camera placed at [0, 0, 4] and looking at the
        world origin.
        '''
        scene = Scene()
        self.scene = scene

        #Camera
        camera = Camera({
            'from': np.array([1., 4., -2.]),
            'to': np.array([1., -2., 4]),
            'up': GT.normalize(np.array([-1., 1., 0.])),
            'fov': 45,
            'width': 10001,
            'height': 10001
        })  # choose very high dimension to avoid rounding error
        render = Render({'camera': camera})
        scene.render = render
Beispiel #2
0
def test_red_sphere_blue_background():
    from Intersectable import Sphere

    scene = Scene()

    # Materials
    red = Material()

    # Lights
    light = Light({'color': [0.8, 0.2, 0.2], 'from': [0, 0, 10], 'power': 0.6})
    scene.lights.append(light)

    # Surfaces
    sphere = Sphere({'radius': 1, 'center': [0, 0, 0], 'material': red})
    scene.surfaces.append(sphere)

    # Camera
    camera = Camera({'from': [0, 0, 4], 'to': [0, 0, 0], 'up': [0, 1, 0], 'fov': 45, 'width': 160, 'height': 120})
    render = Render({'camera': camera, 'bgcolor': [.2, .2, .8], 'output': 'red_sphere_blue_background.png'})
    scene.render = render
    scene.renderScene()
Beispiel #3
0
 def process_render(self, node):
     params = self.create_params(node.attributes)
     params = self.create_params_from_child(node, params)
     self.scene.render = Render(params)
Beispiel #4
0
 def __init__(self, render=Render()):
   self.render = render  # The camera will be set by the parser.
   self.lights = []  # empty lists of lights, needs to be populated by the parser.
   self.surfaces = []  # empty list of surfaces, needs to be populated by the parser.
   self.ambient = np.array([0.1, 0.1, 0.1])  # scene ambient value can be overridden by the xml file spec