import os helper=os.path.join(os.path.dirname(__file__),'..','christmas_train','build_train.py') exec(open(helper,encoding='utf-8-sig').read().split('R=5.5')[0]) OUT=os.path.dirname(os.path.abspath(__file__)) base.name='GINGERBREAD HOUSE — avatar height' cookie=mat('Baked honey gingerbread',(.43,.17,.055),0,.62) edge=mat('Toasted biscuit edges',(.23,.065,.018),0,.65) icing=mat('Vanilla royal icing',(1,.91,.73),0,.36) pink=mat('Raspberry gumdrop',(.8,.035,.13),0,.26) mint=mat('Pistachio candy',(.13,.55,.22),0,.3) root=empty('GingerbreadHouse — 5.5 units tall') def B(n,p,s,m,b=.04):return box(n,p,s,m,root,b) def L(n,pts,r,m):return line(n,pts,r,m,root) def S(n,p,s,m):return ball(n,p,s,m,root) # Model dimensions are in Roblox-friendly units: total height approximately 5.5 studs. B('Thick gingerbread foundation',(0,0,.14),(4.6,3.9,.28),cookie,.15) B('Smooth icing base',(0,0,.29),(4.65,3.95,.17),snow,.12) B('Gingerbread walls',(0,0,1.78),(3.9,3.1,2.9),cookie,.09) vs=[(-1.95,-1.55,3.17),(1.95,-1.55,3.17),(0,-1.55,4.85),(-1.95,1.55,3.17),(1.95,1.55,3.17),(0,1.55,4.85)] me=bpy.data.meshes.new('Solid cookie gables');me.from_pydata(vs,[],[(0,2,1),(3,4,5),(0,1,4,3),(1,2,5,4),(2,0,3,5)]);me.update() o=bpy.data.objects.new('Triangular gingerbread gables',me);base.objects.link(o);finish(o,o.name,cookie,root) ang=math.atan2(1.68,1.95) for side in (-1,1): o=B('Chocolate biscuit roof',(side*1.04,0,4.02),(2.89,3.65,.22),edge,.07);o.rotation_euler.y=side*ang # Smooth, contiguous icing sheet with a gently scalloped eave silhouette. verts=[];faces=[];NU=20;NV=32 for i in range(NU+1): u=i/NU for j in range(NV+1): v=j/NV;y=-1.86+3.72*v x=side*(.015+2.15*u) z=5.17-1.86*u+.055*math.sin(v*math.pi*5)**2 if u>.8:z-=.10*((u-.8)/.2)**2*(.5+.5*math.cos(v*math.pi*12)) verts.append((x,y,z)) for i in range(NU): for j in range(NV): a=i*(NV+1)+j;faces.append((a,a+NV+1,a+NV+2,a+1)) mesh=bpy.data.meshes.new('Flowing icing sheet');mesh.from_pydata(verts,[],faces);mesh.update();ob=bpy.data.objects.new('Smooth flowing roof icing',mesh);base.objects.link(ob);finish(ob,ob.name,snow,root) sol=ob.modifiers.new('Icing thickness','SOLIDIFY');sol.thickness=.11 sub=ob.modifiers.new('Soft icing edges','SUBSURF');sub.levels=2 for p in mesh.polygons:p.use_smooth=True # Chocolate exposed edges outlined with icing, festive candies on slopes. for y in (-1.87,1.87):L('Piped gable icing',[(side*2.17*k/20,y,5.17-1.86*k/20) for k in range(21)],.075,icing) for row in range(2): u=.35+row*.34 for j in range(5): y=-1.35+j*.67;x=side*2.15*u;z=5.22-1.86*u S('Roof gumdrop',(x,y,z),(.13,.13,.12),[red,mint,gold,pink,blue][(j+row)%5]) L('Icing ridge',[(0,-1.9,5.17),(0,1.9,5.17)],.1,icing) # Four striped candy pillars. for x in (-1.88,1.88): for y in (-1.54,1.54): cyl('Candy cane corner',(x,y,1.79),.105,2.85,icing,root) pts=[] for i in range(181): t=i/180;pts.append((x+.108*math.cos(t*math.tau*7),y+.108*math.sin(t*math.tau*7),.39+2.8*t)) L('Spiral red candy stripe',pts,.036,red) # Arched door, thick icing surround and paneling. doorpts=[(-.55,.4),(.55,.4),(.55,1.63)]+[(.55*math.cos(t*math.pi/20),1.63+.55*math.sin(t*math.pi/20)) for t in range(21)]+[(-.55,.4)] verts=[(x,y,z) for y in (-1.59,-1.71) for x,z in doorpts];n=len(doorpts) faces=[tuple(range(n-1,-1,-1)),tuple(range(n,2*n))]+[(i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n)] mesh=bpy.data.meshes.new('Arched door mesh');mesh.from_pydata(verts,[],faces);mesh.update();o=bpy.data.objects.new('Ruby candy door',mesh);base.objects.link(o);finish(o,o.name,red,root) L('Thick door icing border',[(x,-1.74,z) for x,z in doorpts],.075,icing) for x in (-.28,0,.28):L('Door embossed piping',[(x,-1.725,.55),(x,-1.725,1.69)],.018,gold) S('Golden doorknob',(.34,-1.80,1.15),(.075,.07,.075),gold) B('Cookie doorstep',(0,-1.92,.39),(1.35,.55,.18),cookie,.08) def window(x,y,z,side=False): w=empty('Window');w.parent=root;w.location=(x,y,z) if side:w.rotation_euler.z=math.pi/2 box('Chocolate window backing',(0,0,0),(.86,.12,.92),edge,w,.10) box('Warm sugar glass',(0,-.075,0),(.67,.05,.72),light,w,.08) for dx in (-.43,.43):line('Window icing jamb',[(dx,-.13,-.46),(dx,-.13,.46)],.055,icing,w) for dz in (-.46,.46):line('Window icing lintel',[(-.43,-.13,dz),(.43,-.13,dz)],.055,icing,w) box('Window crossbar',(0,-.13,0),(.74,.05,.05),icing,w,.015);box('Window mullion',(0,-.13,0),(.05,.05,.8),icing,w,.015) ball('Snowy sill',(0,-.13,-.51),(.52,.15,.085),snow,w) for x in (-1.20,1.20):window(x,-1.60,1.65) for y in (-.65,.65):window(1.98,y,1.70,True) # Circular wreath and bow on front gable. L('Evergreen wreath',[(.49*math.cos(t*math.tau/64),-1.68,3.55+.49*math.sin(t*math.tau/64)) for t in range(65)],.105,green) for i in range(12): a=i*math.tau/12;S('Wreath foliage',(.49*math.cos(a),-1.70,3.55+.49*math.sin(a)),(.13,.07,.14),green) if i%2==0:S('Wreath berries',(.49*math.cos(a),-1.8,3.55+.49*math.sin(a)),(.055,.045,.055),red) for s in (-1,1): o=S('Red bow loop',(s*.16,-1.84,3.10),(.20,.08,.12),red);o.rotation_euler.y=s*.35 o=B('Bow ribbon tail',(s*.10,-1.83,2.94),(.12,.06,.28),red,.025);o.rotation_euler.y=s*.22 S('Bow knot',(0,-1.91,3.1),(.09,.06,.08),gold) # Front roof fairy lights. pts=[(-1.95+3.9*i/40,-1.91,3.12-.20*math.sin(math.pi*i/40)) for i in range(41)] L('Garland cable',pts,.018,green) for i in range(11): x=-1.9+3.8*i/10;z=3.12-.2*math.sin(math.pi*i/10) cyl('Lamp socket',(x,-1.91,z-.04),.032,.08,gold,root,verts=12) S('Fairy bulb',(x,-1.91,z-.12),(.065,.065,.09),light) # Chimney with icing rim and peppermint disk. B('Cookie chimney',(.85,.75,4.78),(.48,.55,.95),cookie,.05) B('Chocolate chimney rim',(.85,.75,5.27),(.62,.68,.15),edge,.06) for x in (.57,1.13):S('Chimney icing',(x,.75,5.36),(.095,.38,.10),snow) for y in (.44,1.06):S('Chimney icing',(.85,y,5.36),(.31,.09,.10),snow) B('Chimney dark opening',(.85,.75,5.36),(.39,.4,.03),dark,.02) for x in (-2.13,2.13): for j in range(6):S('Base gumdrop',(x,-1.45+j*.58,.48),(.14,.14,.17),[pink,mint,blue,red,gold,mint][j]) for x in (-1.55,1.58): B('Gift box',(x,-1.98,.64),(.45,.45,.52),green if x<0 else red,.055) B('Gift ribbon',(x,-1.98,.65),(.08,.46,.54),gold,.01) B('Gift ribbon',(x,-1.98,.65),(.46,.08,.54),gold,.01) S('Gift bow',(x,-1.98,.94),(.18,.10,.07),gold) root['target_height_studs']=5.5;root['purpose']='Decorative avatar-height gingerbread house; no interior.' studio=empty('PRESENTATION — exclude from game export') floor=mat('Studio blue',(.065,.16,.23),0,.8);box('Studio floor',(0,0,-.09),(200,200,.12),floor,studio,0) scene=bpy.context.scene;scene.unit_settings.system='NONE' world=scene.world;world.use_nodes=True bg=next(n for n in world.node_tree.nodes if n.type=='BACKGROUND');bg.inputs[0].default_value=(.15,.22,.33,1);bg.inputs[1].default_value=.45 def aim(o,p):o.rotation_euler=(Vector(p)-o.location).to_track_quat('-Z','Y').to_euler() for loc,power,size in [((2,-7,10),1500,6),((-6,-2,6),1100,5),((3,6,9),1800,5)]: bpy.ops.object.light_add(type='AREA',location=loc);o=bpy.context.object;o.parent=studio;o.data.energy=power;o.data.shape='DISK';o.data.size=size;aim(o,(0,0,2)) bpy.ops.object.camera_add(location=(9,-13,8));cam=bpy.context.object;cam.parent=studio;aim(cam,(0,0,2.6));cam.data.type='ORTHO';cam.data.ortho_scale=8.2;scene.camera=cam scene.render.engine='CYCLES';scene.cycles.samples=48;scene.render.resolution_x=1300;scene.render.resolution_y=1300;scene.render.resolution_percentage=100 scene.view_settings.view_transform='AgX';scene.render.filepath=os.path.join(OUT,'gingerbread_house_preview.png') # Save asset and render. Presentation rig is clearly separated by parent. bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'gingerbread_house.blend')) bpy.ops.render.render(write_still=True) print('GINGERBREAD_HOUSE_COMPLETE')