ce3c19aed33ff6f29302325e1a9dd860e85275fa
[blender-addons-contrib.git] / add_test_scene_elements / scene_texture_render.py
1 # gpl: author meta-androcto
2
3 import bpy
4 import mathutils
5 import math
6 from math import pi
7 from bpy.props import *
8 from mathutils import Vector
9
10
11 class add_texture_scene(bpy.types.Operator):
12     bl_idname = "objects_texture.add_scene"
13     bl_label = "Create test scene"
14     bl_description = "Cycles Scene with Objects"
15     bl_register = True
16     bl_undo = True
17
18     def execute(self, context):
19         blend_data = context.blend_data
20         ob = bpy.context.active_object
21
22 # add new scene
23         bpy.ops.scene.new(type="NEW")
24         scene = bpy.context.scene
25         bpy.context.scene.render.engine = 'CYCLES'
26         scene.name = "scene_texture_cycles"
27
28 # render settings
29         render = scene.render
30         render.resolution_x = 1080
31         render.resolution_y = 1080
32         render.resolution_percentage = 100
33
34 # add new world
35         world = bpy.data.worlds.new("Cycles_Textures_World")
36         scene.world = world
37         world.use_sky_blend = True
38         world.use_sky_paper = True
39         world.horizon_color = (0.004393, 0.02121, 0.050)
40         world.zenith_color = (0.03335, 0.227, 0.359)
41         world.light_settings.use_ambient_occlusion = True
42         world.light_settings.ao_factor = 0.5
43
44 # add camera
45         bpy.ops.view3d.viewnumpad(type='TOP')
46         bpy.ops.object.camera_add(location=(0, 0, 2.1850), rotation=(0, 0, 0), view_align = True)
47         cam = bpy.context.active_object.data
48         cam.lens = 35
49         cam.draw_size = 0.1
50
51 ### add plane
52         bpy.ops.mesh.primitive_plane_add(enter_editmode=True, location=(0, 0, 0))
53         bpy.ops.mesh.subdivide(number_cuts=10, smoothness=0)
54         bpy.ops.uv.unwrap(method='CONFORMAL', margin=0.001)
55         bpy.ops.object.editmode_toggle()
56         plane = bpy.context.active_object
57
58 # add plane material
59         planeMaterial = blend_data.materials.new("Cycles_Plane_Material")
60         bpy.ops.object.material_slot_add()
61         plane.material_slots[0].material = planeMaterial
62 # Diffuse
63         planeMaterial.preview_render_type = "FLAT"
64         planeMaterial.diffuse_color = (0.2, 0.2, 0.2)
65 # Cycles
66         planeMaterial.use_nodes = True
67
68
69 # Back to Scene
70         sc = bpy.context.scene
71
72         return {'FINISHED'}