This commit is contained in:
listik committed 2026-11-29 15:49:17 +03:00
commit a85391509d
211 files changed
+28903

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
import bpy, math, os
from mathutils import Vector
OUT = r'C:\roblox\hunter\3D models'
os.makedirs(OUT, exist_ok=True)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
def mat(name, color, metallic=0.0, rough=0.35, emission=None):
m=bpy.data.materials.get(name) or bpy.data.materials.new(name)
m.diffuse_color=(*color,1); m.use_nodes=True
p=next((n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED'),None)
p.inputs['Base Color'].default_value=(*color,1)
p.inputs['Metallic'].default_value=metallic; p.inputs['Roughness'].default_value=rough
if emission:
p.inputs['Emission Color'].default_value=(*emission,1); p.inputs['Emission Strength'].default_value=4
return m
dark=mat('Graphite',(0.025,0.04,0.07),0.75,0.24)
metal=mat('Gunmetal',(0.16,0.2,0.27),0.8,0.25)
cyan=mat('CyanGlow',(0.01,0.18,0.28),0.25,0.2,(0.0,0.8,1.0))
orange=mat('OrangeAccent',(0.45,0.06,0.008),0.3,0.24,(1.0,0.16,0.01))
glass=mat('ScopeGlass',(0.02,0.16,0.22),0.3,0.08,(0.0,0.4,0.7))
def cube(n, loc, scale, material, bevel=0.12, rot=(0,0,0)):
bpy.ops.mesh.primitive_cube_add(location=loc, rotation=rot)
o=bpy.context.object; o.name=n; o.scale=scale
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
if bevel:
b=o.modifiers.new('EdgeBevel','BEVEL'); b.width=bevel; b.segments=2
o.data.materials.append(material); return o
def cyl(n, loc, radius, depth, material, rot=(0,0,0), verts=32, bevel=0.08):
bpy.ops.mesh.primitive_cylinder_add(vertices=verts, radius=radius, depth=depth, location=loc, rotation=rot)
o=bpy.context.object; o.name=n
if bevel:
b=o.modifiers.new('EdgeBevel','BEVEL'); b.width=bevel; b.segments=2
o.data.materials.append(material); return o
def torus(n, loc, major, minor, material, rot=(0,0,0)):
bpy.ops.mesh.primitive_torus_add(major_radius=major, minor_radius=minor, major_segments=32, minor_segments=10, location=loc, rotation=rot)
o=bpy.context.object; o.name=n; o.data.materials.append(material); return o
# Main rifle axis is X; muzzle points +X.
cube('Receiver',(0,0,0),(2.15,0.52,0.48),dark,0.18)
cube('UpperArmor',(0.1,0,0.45),(1.45,0.58,0.18),metal,0.1)
cube('LowerModule',(-0.15,0,-0.58),(0.75,0.42,0.25),metal,0.1)
cube('FrontShroud',(2.1,0,0.02),(1.1,0.66,0.42),metal,0.16)
cube('RearStock',(-2.55,0,0.05),(0.85,0.48,0.7),dark,0.18)
cube('StockBrace',(-2.55,0,-0.85),(0.25,0.28,0.65),dark,0.12,rot=(0,math.radians(-14),0))
cube('Grip',(-0.65,0,-0.85),(0.28,0.3,0.72),dark,0.12,rot=(0,math.radians(-13),0))
cube('RearPad',(-3.35,0,0.05),(0.18,0.58,0.72),metal,0.12)
cyl('Barrel',(3.45,0,0.02),0.25,2.2,dark,rot=(0,math.radians(90),0),bevel=0.05)
cyl('Muzzle',(4.55,0,0.02),0.42,0.65,dark,rot=(0,math.radians(90),0),bevel=0.08)
for x in (4.22,4.72): torus('MuzzleRing',(x,0,0.02),0.42,0.07,cyan,rot=(0,math.radians(90),0))
for y in (-0.27,0.27):
cube('MuzzleProng',(4.9,y,0.02),(0.35,0.10,0.12),metal,0.04,rot=(0,0,math.radians(8 if y>0 else -8)))
for y in (-0.58,0.58): cube('SideFin',(2.15,y,0.03),(0.8,0.06,0.16),dark,0.04)
cyl('ScopeBody',(0.15,0,1.25),0.38,2.25,dark,rot=(0,math.radians(90),0),bevel=0.1)
cyl('ScopeFront',(1.28,0,1.25),0.52,0.46,dark,rot=(0,math.radians(90),0),bevel=0.1)
cyl('ScopeLens',(1.53,0,1.25),0.34,0.04,glass,rot=(0,math.radians(90),0),bevel=0.02)
for x in (-0.72,0.95): cyl('ScopeRing',(x,0,1.25),0.48,0.14,metal,rot=(0,math.radians(90),0),bevel=0.04)
cube('ScopeRail',(0,0,0.82),(1.55,0.22,0.08),dark,0.03)
for i in range(12): cube('RailTooth',(-1.45+i*0.25,0,0.96),(0.07,0.18,0.09),metal,0.025)
cube('ScopeHood',(1.12,0,1.25),(0.32,0.58,0.62),dark,0.10)
cube('CyanRail',(0.5,-0.56,0.0),(1.0,0.035,0.08),cyan,0.03)
cube('OrangePanel',(0.25,0,-0.48),(0.55,0.04,0.1),orange,0.02)
cube('OrangeStockAccent',(-2.6,-0.5,0.05),(0.35,0.03,0.12),orange,0.02)
cyl('TopDial',(-0.35,0,1.0),0.28,0.3,orange,rot=(math.radians(90),0,0),bevel=0.06)
for i in range(3): cube('Vent',(1.4+i*0.38,-0.69,0.18),(0.09,0.03,0.15),cyan,0.02,rot=(0,0,math.radians(18)))
cube('Display',(0,0,-1.75),(5.4,2.7,0.08),mat('DisplayMat',(0.008,0.02,0.045),0.1,0.35),0.04)
bpy.ops.object.camera_add(location=(9.5,-15.5,4.6))
cam=bpy.context.object; bpy.context.scene.camera=cam
def point(obj, target): obj.rotation_euler=(Vector(target)-obj.location).to_track_quat('-Z','Y').to_euler()
point(cam,(0,0,0)); cam.data.lens=55
bpy.ops.object.light_add(type='AREA', location=(1.5,-5,6))
key=bpy.context.object; key.data.energy=1200; key.data.size=5; point(key,(0,0,0))
bpy.ops.object.light_add(type='AREA', location=(-4,4,2))
fill=bpy.context.object; fill.data.energy=800; fill.data.color=(0.05,0.35,1); fill.data.size=4; point(fill,(0,0,0))
bpy.ops.object.light_add(type='AREA', location=(4,2,1))
rim=bpy.context.object; rim.data.energy=900; rim.data.color=(1,0.12,0.02); rim.data.size=3; point(rim,(1,0,0))
scene=bpy.context.scene; scene.render.engine='BLENDER_EEVEE'
scene.render.resolution_x=1400; scene.render.resolution_y=800; scene.render.resolution_percentage=100
scene.world.color=(0.004,0.008,0.02)
scene.render.filepath=os.path.join(OUT,'sniper_preview.png')
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'sniper_rifle.blend'))
bpy.ops.render.render(write_still=True)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.export_scene.gltf(filepath=os.path.join(OUT,'sniper_rifle.glb'),export_format='GLB',use_selection=True,export_apply=True,export_animations=False)
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'sniper_rifle.blend'))
print('SAVED',os.path.join(OUT,'sniper_rifle.blend'))