0% found this document useful (0 votes)
19 views3 pages

Code For 3d Monkey

The document contains a Python script for Blender that creates a 3D monkey model, applies a yellow material, and sets up a scene with lighting and a camera. It configures rendering settings for the Cycles engine and saves the Blender file and rendered image with a timestamped filename. The script also includes functions to set smooth shading and focal points for the camera.

Uploaded by

piyush9456789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Code For 3d Monkey

The document contains a Python script for Blender that creates a 3D monkey model, applies a yellow material, and sets up a scene with lighting and a camera. It configures rendering settings for the Cycles engine and saves the Blender file and rendered image with a timestamped filename. The script also includes functions to set smooth shading and focal points for the camera.

Uploaded by

piyush9456789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Code for 3d monkey

if __name__ == '__main__':

# Delete all objects

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

main_object = create_monkey()

yellow_rgba = (1.00, 1.00, 0.00, 1.00)

mat = bpy.data.materials.new(name='yellow')

mat.use_nodes = True

mat.diffuse_color = yellow_rgba

nodes = mat.node_tree.nodes

nodes.clear()

node_material_output = nodes.new(type='ShaderNodeOutputMaterial')

node_diffuse = nodes.new(type='ShaderNodeBsdfDiffuse')

node_diffuse.name = 'Yellow Diffuse'

node_diffuse.inputs['Color'].default_value = yellow_rgba

input = node_material_output.inputs['Surface']

output = node_diffuse.outputs['BSDF']

mat.node_tree.links.new(input, output)

main_object = bpy.context.active_object

main_object.active_material = mat
set_smooth(main_object, level=5)

add_light(location=(5.00, -7.50, 5.00))

bpy.ops.object.camera_add(location=(0.00, -5.00, 0.00))

main_camera = bpy.context.object

bpy.context.scene.camera = main_camera

focal_point = create_focal_point(main_object.location)

set_focal_point(main_camera, focal_point)

bpy.context.scene.render.engine = 'CYCLES'

bpy.context.scene.cycles.samples = 50

bpy.context.scene.render.tile_x = 256

bpy.context.scene.render.tile_y = 256

bpy.context.scene.render.resolution_x = 600

bpy.context.scene.render.resolution_y = 600

bpy.context.scene.render.resolution_percentage = 100

bpy.context.scene.render.image_settings.compression = 100

base_filename = time.strftime('%Y %m %d - %H %M %S - ') + os.path.basename(__file__)

base_filename_no_extension = os.path.splitext(base_filename)[0]

shutil.copy(__file__, base_filename)

bpy.ops.wm.save_as_mainfile(filepath=base_filename_no_extension+'.blend')
bpy.context.scene.render.filepath = base_filename_no_extension+'.png'

bpy.ops.render.render(write_still=True)

You might also like