Hier ist ein Python-Skript für Blender 2.82, das eine einfache 3D-Szene mit einem alten Polizeirevier aus den 80ern erstellt. Der Fokus liegt auf einem 80er-Jahre Computerbildschirm, der Licht abstrahlt.
import bpy
from mathutils import Vector
# Szene zurücksetzen
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
# ---------------------------
# Materialien definieren
# ---------------------------
def material_erstellen(name, base_color, metallic=0.0, roughness=0.5, emission_color=None, emission_strength=0):
mat = bpy.data.materials.new(name)
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
# Alle Nodes löschen
for node in nodes:
nodes.remove(node)
# Material Output
output = nodes.new(type='ShaderNodeOutputMaterial')
output.location = (400, 0)
# Principled BSDF
principled = nodes.new(type='ShaderNodeBsdfPrincipled')
principled.location = (0, 0)
principled.inputs['Base Color'].default_value = base_color
principled.inputs['Metallic'].default_value = metallic
principled.inputs['Roughness'].default_value = roughness
if emission_color and emission_strength > 0:
emission = nodes.new(type='ShaderNodeEmission')
emission.location = (-200, 0)
emission.inputs['Color'].default_value = emission_color
emission.inputs['Strength'].default_value = emission_strength
add_shader = nodes.new(type='ShaderNodeAddShader')
add_shader.location = (200, 0)
links.new(emission.outputs['Emission'], add_shader.inputs[0])
links.new(principled.outputs['BSDF'], add_shader.inputs[1])
links.new(add_shader.outputs['Shader'], output.inputs['Surface'])
else:
links.new(principled.outputs['BSDF'], output.inputs['Surface'])
return mat
# ---------------------------
# Raum erstellen (Wände, Boden, Decke)
# ---------------------------
def raum_erstellen():
# Boden
bpy.ops.mesh.primitive_plane_add(size=10, location=(0, 0, 0))
boden = bpy.context.active_object
boden.name = "Boden"
boden_mat = material_erstellen("Boden_Mat", (0.1, 0.1, 0.1, 1), roughness=0.8)
boden.data.materials.append(boden_mat)
# Wände (4 Stück)
wand_mat = material_erstellen("Wand_Mat", (0.3, 0.3, 0.35, 1), roughness=0.7)
wand_koordinaten = [
((0, -5, 2.5), (0, 0, 0)), # Rückwand
((0, 5, 2.5), (0, 0, 3.14159)), # Vorderwand
((-5, 0, 2.5), (0, 0, 1.5708)), # Linke Wand
((5, 0, 2.5), (0, 0, -1.5708)) # Rechte Wand
]
wände = []
for pos, rot in wand_koordinaten:
bpy.ops.mesh.primitive_plane_add(size=10, location=pos, rotation=rot)
wand = bpy.context.active_object
wand.name = "Wand"
wand.data.materials.append(wand_mat)
wände.append(wand)
# Decke
bpy.ops.mesh.primitive_plane_add(size=10, location=(0, 0, 5), rotation=(3.14159, 0, 0))
decke = bpy.context.active_object
decke.name = "Decke"
decke.data.materials.append(wand_mat)
return boden, wände, decke
# ---------------------------
# Alter Schreibtisch
# ---------------------------
def schreibtisch_erstellen():
# Tischplatte
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 1))
tischplatte = bpy.context.active_object
tischplatte.scale[2] = 0.1
tischplatte.name = "Tischplatte"
holz_mat = material_erstellen("Holz_Mat", (0.4, 0.25, 0.1, 1), roughness=0.6)
tischplatte.data.materials.append(holz_mat)
# Tischbeine
beine = []
for x in [-0.9, 0.9]:
for y in [-0.9, 0.9]:
bpy.ops.mesh.primitive_cube_add(size=0.2, location=(x, y, 0.5))
bein = bpy.context.active_object
bein.scale[2] = 2.5
bein.name = "Tischbein"
bein.data.materials.append(holz_mat)
beine.append(bein)
return tischplatte, beine
# ---------------------------
# 80er Jahre Computerbildschirm
# ---------------------------
def computerbildschirm_erstellen():
# Monitor Gehäuse
bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0.6, 1.3))
gehäuse = bpy.context.active_object
gehäuse.name = "Monitor_Gehäuse"
gehäuse.scale[0] = 1.2
gehäuse.scale[1] = 0.4
gehäuse.scale[2] = 0.9
gehäuse_mat = material_erstellen("Monitor_Gehäuse_Mat", (0.05, 0.05, 0.05, 1), roughness=0.4, metallic=0.3)
gehäuse.data.materials.append(gehäuse_mat)
# Bildschirmfläche (Glas)
bpy.ops.mesh.primitive_plane_add(size=1.8, location=(0, 0.81, 1.3))
bildschirm = bpy.context.active_object
bildschirm.name = "Bildschirm"
bildschirm.rotation_euler[0] = 0
bildschirm_mat = material_erstellen("Bildschirm_Mat", (0.0, 0.1, 0.0, 1), emission_color=(0.0, 1.0, 0.0, 1), emission_strength=5, roughness=0.1)
bildschirm.data.materials.append(bildschirm_mat)
# Standfuß
bpy.ops.mesh.primitive_cube_add(size=0.3, location=(0, 0.6, 0.7))
standfuss = bpy.context.active_object
standfuss.name = "Standfuss"
standfuss.scale[0] = 1.0
standfuss.scale[1] = 0.3
standfuss.scale[2] = 0.2
standfuss.data.materials.append(gehäuse_mat)
# Lichtquelle (Point Light) vor dem Bildschirm
bpy.ops.object.light_add(type='POINT', location=(0, 0.9, 1.3))
licht = bpy.context.active_object
licht.name = "Monitor_Licht"
licht.data.energy = 50
licht.data.color = (0.0, 1.0, 0.0)
licht.data.shadow_soft_size = 0.3
return gehäuse, bildschirm, standfuss, licht
# ---------------------------
# Kamera und Licht
# ---------------------------
def kamera_und_licht_erstellen():
# Kamera
bpy.ops.object.camera_add(location=(5, -6, 4), rotation=(1.1, 0, 0.8))
kamera = bpy.context.active_object
kamera.name = "Kamera"
bpy.context.scene.camera = kamera
# Deckenlicht (Sun)
bpy.ops.object.light_add(type='SUN', location=(0, 0, 10))
sonne = bpy.context.active_object
sonne.name = "Deckenlicht"
sonne.data.energy = 1.0
sonne.rotation_euler = (0.7, 0, 0.7)
return kamera, sonne
# ---------------------------
# Szene aufbauen
# ---------------------------
raum_erstellen()
schreibtisch_erstellen()
computerbildschirm_erstellen()
kamera_und_licht_erstellen()
print("Szene 'Altes Polizeirevier 80er' wurde erstellt.")
So verwendest du das Skript:
- Öffne Blender 2.82.
- Öffne den Scripting-Tab.
- Erstelle ein neues Text-Dokument und füge das Skript ein.
- Klicke auf Run Script.
Was das Skript macht:
- Erstellt einen einfachen Raum mit Boden, Wänden und Decke.
- Fügt einen alten Holztisch hinzu.
- Baut einen 80er-Jahre Computerbildschirm mit grünem leuchtendem Bildschirm und einer Lichtquelle davor.
- Platziert eine Kamera und ein Sonnenlicht für die Beleuchtung.
Hinweise:
- Das Modell ist einfach gehalten, um als Basis zu dienen. Du kannst es mit weiteren Details erweitern (Stühle, Akten, Poster etc.).
- Die Lichtquelle am Bildschirm simuliert das typische grüne Leuchten alter CRT-Monitore.
- Materialien sind mit Principled BSDF und Emission für den Bildschirm realistisch gestaltet.
Wenn du möchtest, kann ich dir auch helfen, weitere Details oder Animationen hinzuzufügen!