コード例 #1
0
ファイル: test_video.py プロジェクト: acosta/miru
def render_moon(scene):

    light = Light(Color(1.0, 1.0, 1.0, 1.0), 1.0)
    light.transform.position = Vector3(0.0, 2.0, -2.0)
    scene.set_light(light)

    lambertianTintMaterial = Material()
    lambertianTintMaterial.albedo = Color(1.0, 1.0, 1.0, 1.0)
    lambertianTintMaterial.shader = LambertianTintShader()

    s1_earth = Sphere(0.6)
    s1_earth.transform.position = Vector3(0, 0, 1.5)
    s1_earth.material = lambertianTintMaterial.clone()
    scene.add_objects(s1_earth)

    s2_moon = Sphere(0.4)
    s2_moon.transform.position = Vector3(-0.2, -0.5, 1.2)
    s2_moon.material = lambertianTintMaterial.clone()
    s2_moon.material.set_texture(Texture("images/moon.jpg"))
    scene.add_objects(s2_moon)

    v1 = Vector3(0.0, 1.5, 0.5)
    v2 = Vector3(0.5, -1.0, 0.0)
    animation_velocity = 0.4

    def update_method(t):
        p = Vector3(-0.2, -0.5, 1.2)
        p = p.add(v1.multiply(np.cos(animation_velocity * t * np.pi)))
        p = p.add(v2.multiply(np.sin(animation_velocity * t * np.pi)))

        s2_moon.transform.position = p
        s2_moon.transform.rotation = Vector3(
            0.0, np.mod(0.5 * animation_velocity * t, 360), 0.0)

    return update_method
コード例 #2
0
ファイル: test_texture.py プロジェクト: acosta/miru
try:
    range = xrange
except NameError:
    pass

total_sphere = random.randint(1,15)

scene_test = Scene()
scene_test.background_color = Color.random()

light = Light(Color(1.0, 1.0, 1.0, 1.0), 1.0)
light.transform.position = Vector3(1.0, 2.0, 1.0)
scene_test.set_light(light)

lambertianTintMaterial = Material()
lambertianTintMaterial.albedo = Color(1.0, 1.0, 1.0, 1.0)
lambertianTintMaterial.shader = LambertianTintShader()

# s1 = Sphere(0.6)
# s1.transform.position = Vector3(0, 2.4, 4)
# s1.material = lambertianTintMaterial
# scene_test.add_objects(s1)

# s2 = Sphere(1.2)
# s2.transform.position = Vector3(-0.2, -2.4, 4)
# s2.material = lambertianTintMaterial.clone()
# s2.material.set_texture(Texture("images/moon.jpg"))
# scene_test.add_objects(s2)

zelda_texture = Texture("images/zelda.jpg")