Motion blurred transformations are enabled by setting the l2w_motion
matrix for each geometry object. By default, it is set to the l2w matrix.
Motion blurred deforming geometry can be easily enabled by setting the
motion position for each vertex. Here's an example of how to create
a motion blurred, deforming cube:
class DeformingCubeGeometry(Geometry):
def generate(self):
v0 = Vertex((-0.5, -0.5, -0.5), (0,1), (-1,-1,-1))
v1 = Vertex(( 0.5, -0.5, -0.5), (0,0))
v2 = Vertex(( 0.5, 0.5, -0.5), (1,0))
v3 = Vertex((-0.5, 0.5, -0.5), (1,1))
self.quad(v1, v0, v3, v2)
v0 = Vertex((-0.5, -0.5, 0.5), (0,0))
v1 = Vertex(( 0.5, -0.5, 0.5), (0,1))
v2 = Vertex(( 0.5, 0.5, 0.5), (1,1))
v3 = Vertex((-0.5, 0.5, 0.5), (1,0))
self.quad(v0, v1, v2, v3)
v0 = Vertex((-0.5, 0.5, -0.5), (0,0))
v1 = Vertex((-0.5, -0.5, -0.5), (0,1), (-1,-1,-1))
v2 = Vertex((-0.5, -0.5, 0.5), (1,1))
v3 = Vertex((-0.5, 0.5, 0.5), (1,0))
self.quad(v0, v1, v2, v3)
v0 = Vertex(( 0.5, -0.5, -0.5), (0,0))
v1 = Vertex(( 0.5, 0.5, -0.5), (0,1))
v2 = Vertex(( 0.5, 0.5, 0.5), (1,1))
v3 = Vertex(( 0.5, -0.5, 0.5), (1,0))
self.quad(v0, v1, v2, v3)
v0 = Vertex(( 0.5, 0.5, -0.5), (0,0))
v1 = Vertex((-0.5, 0.5, -0.5), (0,1))
v2 = Vertex((-0.5, 0.5, 0.5), (1,1))
v3 = Vertex(( 0.5, 0.5, 0.5), (1,0))
self.quad(v0, v1, v2, v3)
v1 = Vertex((-0.5, -0.5, -0.5), (0,0), (-1,-1,-1))
v1 = Vertex(( 0.5, -0.5, -0.5), (0,1))
v2 = Vertex(( 0.5, -0.5, 0.5), (1,0))
v3 = Vertex((-0.5, -0.5, 0.5), (1,1))
self.quad(v0, v1, v2, v3)
cube = DeformingCubeGeometry()
cube.l2w = matrix.Matrix()
cube.l2w.set_translate(0, 1, -1)
cube.l2w.lookat(3,4,5)
cube.l2w_motion = matrix.Matrix()
cube.l2w_motion.set_translate(0, 1, 1)
cube.l2w_motion.lookat(3,4,5)
cube.l2w_motion.rotate(0, 15, 0)
material = DiffuseMaterial(0.5, 0.2, 0.3)
map = MapMaterial("texture.ppm")
material2.Kd = map
view.add_geometry(cube, material2, 3)