修改
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1008 KiB |
22
toModel.py
22
toModel.py
@@ -95,7 +95,7 @@ nothing_mat = create_nothing_material()
|
|||||||
emissive_mat = create_emissive_material()
|
emissive_mat = create_emissive_material()
|
||||||
|
|
||||||
# 创建更精确的抛物面
|
# 创建更精确的抛物面
|
||||||
def create_parabolic_surface(face_f, size=2.0, resolution=32):
|
def create_parabolic_surface(face_f, size=1.0, resolution=32):
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
|
|
||||||
# 创建抛物面网格
|
# 创建抛物面网格
|
||||||
@@ -135,7 +135,7 @@ def create_parabolic_surface(face_f, size=2.0, resolution=32):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
# 创建双曲面
|
# 创建双曲面
|
||||||
def create_hyperbolic_surface(face_f, face_g, size=2.0, resolution=32):
|
def create_hyperbolic_surface(face_f, face_g, size=1.0, resolution=32):
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
|
|
||||||
# 创建双曲面网格
|
# 创建双曲面网格
|
||||||
@@ -197,28 +197,36 @@ def create_geometry(obj_data):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if face_geom == "plane":
|
if face_geom == "plane":
|
||||||
bpy.ops.mesh.primitive_plane_add(size=2)
|
bpy.ops.mesh.primitive_plane_add(size=1) # 减小平面尺寸
|
||||||
mesh = bpy.context.active_object
|
mesh = bpy.context.active_object
|
||||||
|
elif face_geom == "circle":
|
||||||
|
# 创建圆形平面
|
||||||
|
bpy.ops.mesh.primitive_circle_add(vertices=32, radius=0.5)
|
||||||
|
mesh = bpy.context.active_object
|
||||||
|
# 填充圆形
|
||||||
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
bpy.ops.mesh.edge_face_add()
|
||||||
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
elif face_geom == "parabola":
|
elif face_geom == "parabola":
|
||||||
if face_f < 1e9 and face_f > 0.1: # 使用精确抛物面
|
if face_f < 1e9 and face_f > 0.1: # 使用精确抛物面
|
||||||
mesh = create_parabolic_surface(face_f)
|
mesh = create_parabolic_surface(face_f)
|
||||||
else: # 使用简化圆锥
|
else: # 使用简化圆锥
|
||||||
bpy.ops.mesh.primitive_cone_add(vertices=32, radius1=1.5, radius2=0.1, depth=2.0)
|
bpy.ops.mesh.primitive_cone_add(vertices=32, radius1=0.75, radius2=0.05, depth=1.0)
|
||||||
mesh = bpy.context.active_object
|
mesh = bpy.context.active_object
|
||||||
elif face_geom == "hyperbola":
|
elif face_geom == "hyperbola":
|
||||||
if abs(face_f) > 0.1 and abs(face_g) > 0.1: # 使用精确双曲面
|
if abs(face_f) > 0.1 and abs(face_g) > 0.1: # 使用精确双曲面
|
||||||
mesh = create_hyperbolic_surface(face_f, face_g)
|
mesh = create_hyperbolic_surface(face_f, face_g)
|
||||||
else: # 使用简化环面
|
else: # 使用简化环面
|
||||||
bpy.ops.mesh.primitive_torus_add(major_radius=1.0, minor_radius=0.3)
|
bpy.ops.mesh.primitive_torus_add(major_radius=0.5, minor_radius=0.15)
|
||||||
mesh = bpy.context.active_object
|
mesh = bpy.context.active_object
|
||||||
else:
|
else:
|
||||||
# 默认立方体
|
# 默认立方体
|
||||||
bpy.ops.mesh.primitive_cube_add(size=1.0)
|
bpy.ops.mesh.primitive_cube_add(size=0.5)
|
||||||
mesh = bpy.context.active_object
|
mesh = bpy.context.active_object
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"创建几何体时出错: {e}")
|
print(f"创建几何体时出错: {e}")
|
||||||
# 备用:创建简单立方体
|
# 备用:创建简单立方体
|
||||||
bpy.ops.mesh.primitive_cube_add(size=0.5)
|
bpy.ops.mesh.primitive_cube_add(size=0.25)
|
||||||
mesh = bpy.context.active_object
|
mesh = bpy.context.active_object
|
||||||
|
|
||||||
# 设置对象属性
|
# 设置对象属性
|
||||||
|
|||||||
Reference in New Issue
Block a user