Added previewPass

This commit is contained in:
Jaime van Kessel 2017-11-08 15:27:50 +01:00
parent 303cf33de1
commit 06045f036e

28
cura/PreviewPass.py Normal file
View file

@ -0,0 +1,28 @@
# Copyright (c) 2017 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.
from UM.Application import Application
from UM.View.RenderPass import RenderPass
from UM.Scene.Camera import Camera
## A render pass subclass that renders everything with default parameters, but can be used with a non-default camera
#
# This is useful to get a preview image of a scene taken from a different location as the active camera.
class PreviewPass(RenderPass):
def __init__(self, width, height):
super().__init__("preview", width, height, 0)
self._camera = Application.getInstance().getController().getScene().getActiveCamera()
self._renderer = Application.getInstance().getRenderer()
# Override the camera to be used for this render pass
def setCamera(self, camera: Camera):
self._camera = camera
def render(self):
self.bind()
for batch in self._renderer.getBatches():
batch.render(self._camera)
self.release()