scene.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:blender-python-gif 作者: fhoehl 项目源码 文件源码
def update_scene(scene):
    """Update the scene before rendering."""

    LOGGER.info("Hello!")

    cube = scene.objects["Cube"]

    rotation_vector = (uniform(0, 360),
                       uniform(0, 360),
                       uniform(0, 360))

    rotation_vector_radians = (radians(scalar) for scalar in rotation_vector)

    rotation_euler_angles = Euler(rotation_vector_radians, 'XYZ')

    cube.rotation_euler.rotate(rotation_euler_angles)

    cube.scale.x = cube.scale.y = cube.scale.z = uniform(1, 3)

    # Equivalent to:
    # cube.scale = Vector(3 * [uniform(1, 3)])

    cube.location.x = uniform(-2, 2)
    cube.location.y = uniform(-2, 2)
    cube.location.z = uniform(-2, 2)

    # Equivalent to
    # cube.location = Vector((uniform(-2, 2),
    #                        uniform(-2, 2),
    #                        uniform(-2, 2)))

    cube.active_material.diffuse_color.h = uniform(0, 1)
    cube.active_material.diffuse_color.s = uniform(.8, 1)
    cube.active_material.diffuse_color.v = uniform(.8, 1)

    for vertex in cube.data.vertices:
        vertex.co = Vector((vertex.co[0] + uniform(0, 0.1),
                            vertex.co[1] + uniform(0, 0.1),
                            vertex.co[2] + uniform(0, 0.1)))

    cube.data.materials[0].diffuse_shader = "TOON"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号