workshop rework
This commit is contained in:
1 parent
a3a80dfa16
commit
fb39e290c0
115 files changed
+1865
-497
No files matched your search
@@ -0,0 +1,58 @@
|
||||
"""Blender --background --python tools/create_character.py (does not need UE)."""
|
||||
from pathlib import Path
|
||||
|
||||
import bpy
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
target = root / "source_assets/character/character.blend"
|
||||
if target.exists():
|
||||
raise RuntimeError(f"Plik juz istnieje: {target}. Generator nie nadpisuje Twojego modelu.")
|
||||
bpy.ops.object.select_all(action="SELECT")
|
||||
bpy.ops.object.delete(use_global=False)
|
||||
collection = bpy.data.collections.new("Character")
|
||||
bpy.context.scene.collection.children.link(collection)
|
||||
|
||||
|
||||
def material(name, color):
|
||||
mat = bpy.data.materials.new(name)
|
||||
mat.use_nodes = True
|
||||
bsdf = mat.node_tree.nodes.get("Principled BSDF")
|
||||
bsdf.inputs["Base Color"].default_value = (*color, 1)
|
||||
bsdf.inputs["Roughness"].default_value = 0.5
|
||||
mat.diffuse_color = (*color, 1)
|
||||
return mat
|
||||
|
||||
|
||||
blue = material("Body_Blue", (0.03, 0.3, 0.8))
|
||||
orange = material("Head_Orange", (0.9, 0.22, 0.04))
|
||||
dark = material("Eyes", (0.01, 0.01, 0.015))
|
||||
|
||||
|
||||
def part(name, position, scale, mat, sphere=False):
|
||||
if sphere:
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=24, ring_count=16, radius=0.5, location=position)
|
||||
else:
|
||||
bpy.ops.mesh.primitive_cube_add(size=1, location=position)
|
||||
obj = bpy.context.object
|
||||
obj.name = name
|
||||
obj.scale = scale
|
||||
for owner in list(obj.users_collection):
|
||||
owner.objects.unlink(obj)
|
||||
collection.objects.link(obj)
|
||||
obj.data.materials.append(mat)
|
||||
if sphere:
|
||||
for polygon in obj.data.polygons:
|
||||
polygon.use_smooth = True
|
||||
return obj
|
||||
|
||||
|
||||
part("Body", (0, 0, 0.9), (0.55, 0.8, 0.9), blue)
|
||||
part("Head", (0, 0, 1.75), (0.7, 0.7, 0.7), orange, True)
|
||||
part("LeftLeg", (0, -0.23, 0.25), (0.35, 0.3, 0.5), blue)
|
||||
part("RightLeg", (0, 0.23, 0.25), (0.35, 0.3, 0.5), blue)
|
||||
part("Eye_L", (0.31, -0.14, 1.82), (0.12, 0.12, 0.12), dark, True)
|
||||
part("Eye_R", (0.31, 0.14, 1.82), (0.12, 0.12, 0.12), dark, True)
|
||||
bpy.context.scene.unit_settings.system = "METRIC"
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(target))
|
||||
print("Gotowy model: " + str(target))
|
||||
Reference in new issue
Block a user