85 lines
3.7 KiB
Python
85 lines
3.7 KiB
Python
import bpy, math, os
|
|
from mathutils import Vector
|
|
sc=bpy.context.scene
|
|
root=next(c for c in sc.collection.children if c.name.startswith('Spirit_Winter_Model'))
|
|
# Work on an independent scene and independent meshes.
|
|
original=sc
|
|
sc=bpy.data.scenes.new('Spirit_Winter_Refined')
|
|
for obj in original.objects:
|
|
cp=obj.copy()
|
|
if obj.data: cp.data=obj.data.copy()
|
|
sc.collection.objects.link(cp)
|
|
bpy.context.window.scene=sc
|
|
sc.world=original.world.copy()
|
|
def find(prefix): return [o for o in sc.objects if o.name.startswith('SW_'+prefix)]
|
|
white=find('Hood')[0].data.materials[0]
|
|
ice=find('Hood_lower')[0].data.materials[0]
|
|
def cube(name,loc,size,material,angle=0):
|
|
bpy.ops.mesh.primitive_cube_add(size=1,location=loc)
|
|
o=bpy.context.object; o.name=name; o.dimensions=size
|
|
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
|
o.rotation_euler[1]=angle; o.data.materials.append(material)
|
|
m=o.modifiers.new('Edge highlights','BEVEL'); m.width=.035; m.segments=2
|
|
o.modifiers.new('Normals','WEIGHTED_NORMAL')
|
|
return o
|
|
for o in list(sc.objects):
|
|
if o.name.startswith(('SW_Hood','SW_Shoulder')): sc.collection.objects.unlink(o)
|
|
for sign in (-1,1):
|
|
for x,z in [(.72,4.1),(.87,4.36),(.94,4.64),(.88,4.92),(.72,5.17),(.46,5.35),(.16,5.44)]:
|
|
cube('IceHood',(sign*x,-.07,z),(.45,.9,.4),white)
|
|
for x,z,w,ang in [(1.12,3.87,1.15,-.16),(1.62,3.83,.95,-.12),(1.12,4.07,.95,-.4),(1.65,4.2,.75,-.45),(2.0,3.67,.65,0)]:
|
|
cube('IceShoulder',(sign*x,.08,z),(w,.65,.29),white,sign*ang)
|
|
cube('ShoulderUnderside',(sign*1.55,.2,3.53),(1.4,.67,.22),ice)
|
|
for o in find('Face'):
|
|
o.scale.x=.93; o.scale.z=.88
|
|
for o in find('Eye'): o.scale*=.8
|
|
for o in find('Robe')+find('Lapel'):
|
|
o.location.z=3.35+(o.location.z-3.35)*.76
|
|
o.scale.z*=.78
|
|
o.location.x*=1.09; o.scale.x*=1.1
|
|
for o in find('Tail'):
|
|
for v in o.data.vertices: v.co.z=3.35+(v.co.z-3.35)*.76
|
|
for o in find('Chest_frame'): o.scale*=.78
|
|
for o in find('Chest_crystal'):
|
|
for v in o.data.vertices:
|
|
v.co.x*=.8; v.co.z=3.49+(v.co.z-3.49)*.8
|
|
for o in find('Forehead'):
|
|
for v in o.data.vertices:
|
|
v.co.x*=.77; v.co.z=5.44+(v.co.z-5.44)*.8
|
|
for o in find('Cap')+find('Neck'):
|
|
o.location.z-=.27
|
|
for o in find('GoldenHook'):
|
|
for sp in o.data.splines:
|
|
for p in sp.points:
|
|
p.co.x*=.78; p.co.z=6.08+(p.co.z-6.35)*.78
|
|
o.data.bevel_depth=.09
|
|
# Copy materials so previous versions retain their original appearance.
|
|
mapping={}
|
|
for o in sc.objects:
|
|
if o.type not in ('MESH','CURVE'): continue
|
|
for slot in o.material_slots:
|
|
m=slot.material
|
|
if not m: continue
|
|
if m.name not in mapping:
|
|
cp=m.copy(); mapping[m.name]=cp
|
|
p=next(n for n in cp.node_tree.nodes if n.type=='BSDF_PRINCIPLED')
|
|
if 'Cyan' in m.name: p.inputs['Emission Strength'].default_value=.08
|
|
if 'Snow' in m.name: p.inputs['Base Color'].default_value=(.56,.69,.9,1)
|
|
p.inputs['Roughness'].default_value=.3
|
|
slot.material=mapping[m.name]
|
|
for o in sc.objects:
|
|
if o.type=='LIGHT': o.data.energy*=.42
|
|
cam=next(o for o in sc.objects if o.type=='CAMERA'); sc.camera=cam
|
|
cam.location=(.15,-18,4.8)
|
|
cam.rotation_euler=(Vector((0,0,3.85))-cam.location).to_track_quat('-Z','Y').to_euler()
|
|
cam.data.ortho_scale=7.2
|
|
sc.render.engine='CYCLES'; sc.cycles.samples=48; sc.cycles.use_denoising=True
|
|
sc.view_settings.view_transform='AgX'
|
|
sc.render.resolution_x=900; sc.render.resolution_y=1100; sc.render.resolution_percentage=100
|
|
sc.render.image_settings.file_format='PNG'
|
|
out=r'C:\roblox\Ornament Generator RNG\blender\spirit_winter_refined'
|
|
sc.render.filepath=out+'.png'
|
|
bpy.ops.wm.save_as_mainfile(filepath=out+'.blend')
|
|
bpy.ops.render.render(write_still=True)
|
|
print(sc.render.filepath)
|