Certainly! Below is a Python script designed for Blender that sets up a basic primitive layout for the 'Library of Whispers' scene. This script utilizes the bpy module to create the scene elements as specified:
import bpy
import math
# Clear the Scene: Delete all existing objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
# Define Parameters
room_radius = 10.0 # Radius of the circular room
bookshelf_count = 12 # Number of bookshelves
bookshelf_width = 1.5 # Width of each bookshelf
bookshelf_depth = 0.5 # Depth of each bookshelf
bookshelf_height = 8.0 # Height of each bookshelf
lectern_size = (1.0, 1.0, 1.5) # Dimensions of the lectern (X, Y, Z)
book_size = (0.8, 0.6, 0.1) # Dimensions of the book (X, Y, Z)
# Create the Floor
bpy.ops.mesh.primitive_cylinder_add(
radius=room_radius,
depth=0.1,
location=(0, 0, 0)
)
floor = bpy.context.object
floor.name = "Floor"
# Create the Central Lectern
bpy.ops.mesh.primitive_cube_add(
size=1,
location=(0, 0, lectern_size[2] / 2)
)
lectern = bpy.context.object
lectern.name = "Lectern"
lectern.scale = lectern_size
# Create the Book Placeholder
bpy.ops.mesh.primitive_cube_add(
size=1,
location=(0, 0, lectern_size[2] + book_size[2] / 2)
)
book = bpy.context.object
book.name = "Book"
book.scale = book_size
book.rotation_euler = (math.radians(30), 0, 0) # Rotate around X-axis
# Create Bookshelves
angle_increment = 2 * math.pi / bookshelf_count
for i in range(bookshelf_count):
angle = i * angle_increment
x = room_radius * math.cos(angle)
y = room_radius * math.sin(angle)
bpy.ops.mesh.primitive_cube_add(
size=1,
location=(x, y, bookshelf_height / 2)
)
bookshelf = bpy.context.object
bookshelf.name = f"Bookshelf_{i+1}"
bookshelf.scale = (bookshelf_width, bookshelf_depth, bookshelf_height)
bookshelf.rotation_euler = (0, 0, angle + math.pi / 2) # Face towards center
Explanation of the Script:
-
Clear the Scene: The script begins by selecting and deleting all existing objects in the scene to ensure a clean slate.
-
Define Parameters: Variables are defined at the top of the script for easy adjustment of the room and object dimensions.
-
Create the Floor: A cylinder primitive is added at the world origin to represent the circular floor, scaled according to room_radius with a small Z-height.
-
Create the Central Lectern: A cube primitive is added at the world origin, scaled to lectern_size, and positioned slightly above the floor.
-
Create the Book Placeholder: Another cube primitive is added to represent a book, scaled to , positioned on top of the lectern, and rotated around its local X-axis to appear open.