1 # gpl: author meta-androcto
4 from bpy
.types
import Operator
7 class add_cycles_scene(Operator
):
8 bl_idname
= "objects_cycles.add_scene"
9 bl_label
= "Create test scene"
10 bl_description
= "Cycles renderer Scene with Objects"
11 bl_options
= {'REGISTER'}
13 def execute(self
, context
):
15 blend_data
= context
.blend_data
18 bpy
.ops
.scene
.new(type="NEW")
19 scene
= bpy
.context
.scene
20 bpy
.context
.scene
.render
.engine
= 'CYCLES'
21 scene
.name
= "scene_object_cycles"
25 render
.resolution_x
= 1920
26 render
.resolution_y
= 1080
27 render
.resolution_percentage
= 50
30 world
= bpy
.data
.worlds
.new("Cycles_Object_World")
32 world
.use_sky_blend
= True
33 world
.use_sky_paper
= True
34 world
.horizon_color
= (0.004393, 0.02121, 0.050)
35 world
.zenith_color
= (0.03335, 0.227, 0.359)
36 world
.light_settings
.use_ambient_occlusion
= True
37 world
.light_settings
.ao_factor
= 0.25
40 bpy
.ops
.object.camera_add(
41 location
=(7.48113, -6.50764, 5.34367),
42 rotation
=(1.109319, 0.010817, 0.814928)
44 cam
= bpy
.context
.active_object
.data
47 bpy
.ops
.view3d
.viewnumpad(type='CAMERA')
50 bpy
.ops
.object.lamp_add(
51 type="POINT", location
=(4.07625, 1.00545, 5.90386),
52 rotation
=(0.650328, 0.055217, 1.866391)
54 lamp1
= bpy
.context
.active_object
.data
55 lamp1
.name
= "Point_Right"
58 lamp1
.shadow_method
= "RAY_SHADOW"
59 lamp1
.use_sphere
= True
62 bpy
.ops
.object.lamp_add(
63 type="POINT", location
=(-0.57101, -4.24586, 5.53674),
64 rotation
=(1.571, 0, 0.785)
66 lamp2
= bpy
.context
.active_object
.data
67 lamp2
.name
= "Point_Left"
72 bpy
.ops
.mesh
.primitive_cube_add()
73 bpy
.ops
.object.editmode_toggle()
74 bpy
.ops
.mesh
.subdivide(number_cuts
=2)
75 bpy
.ops
.uv
.unwrap(method
='CONFORMAL', margin
=0.001)
76 bpy
.ops
.object.editmode_toggle()
77 cube
= bpy
.context
.active_object
80 cubeMaterial
= blend_data
.materials
.new("Cycles_Cube_Material")
81 bpy
.ops
.object.material_slot_add()
82 cube
.material_slots
[0].material
= cubeMaterial
84 cubeMaterial
.preview_render_type
= "CUBE"
85 cubeMaterial
.diffuse_color
= (1.000, 0.373, 0.00)
87 cubeMaterial
.use_nodes
= True
90 bpy
.ops
.mesh
.primitive_monkey_add(location
=(-0.1, 0.08901, 1.505))
91 bpy
.ops
.transform
.rotate(value
=(1.15019), axis
=(0, 0, 1))
92 bpy
.ops
.transform
.rotate(value
=(-0.673882), axis
=(0, 1, 0))
93 bpy
.ops
.transform
.rotate(value
=-0.055, axis
=(1, 0, 0))
95 bpy
.ops
.object.modifier_add(type='SUBSURF')
96 bpy
.ops
.object.shade_smooth()
97 monkey
= bpy
.context
.active_object
100 monkeyMaterial
= blend_data
.materials
.new("Cycles_Monkey_Material")
101 bpy
.ops
.object.material_slot_add()
102 monkey
.material_slots
[0].material
= monkeyMaterial
104 monkeyMaterial
.preview_render_type
= "MONKEY"
105 monkeyMaterial
.diffuse_color
= (0.239, 0.288, 0.288)
107 monkeyMaterial
.use_nodes
= True
110 bpy
.ops
.mesh
.primitive_plane_add(
111 radius
=50, view_align
=False,
112 enter_editmode
=False, location
=(0, 0, -1)
114 bpy
.ops
.object.editmode_toggle()
115 bpy
.ops
.transform
.rotate(
116 value
=-0.8, axis
=(0, 0, 1),
117 constraint_axis
=(False, False, True)
119 bpy
.ops
.uv
.unwrap(method
='CONFORMAL', margin
=0.001)
120 bpy
.ops
.object.editmode_toggle()
121 plane
= bpy
.context
.active_object
124 planeMaterial
= blend_data
.materials
.new("Cycles_Plane_Material")
125 bpy
.ops
.object.material_slot_add()
126 plane
.material_slots
[0].material
= planeMaterial
128 planeMaterial
.preview_render_type
= "FLAT"
129 planeMaterial
.diffuse_color
= (0.2, 0.2, 0.2)
131 planeMaterial
.use_nodes
= True
133 except Exception as e
:
134 self
.report({'WARNING'},
135 "Some operations could not be performed (See Console for more info)")
137 print("\n[Add Advanced Objects]\nOperator: "
138 "objects_cycles.add_scene\nError: {}".format(e
))