当前位置:   article > 正文

blender操作模型数据的若干代码_csdn blender bpy.ops.mesh.subdivide

csdn blender bpy.ops.mesh.subdivide

1. 导出obj:        

  1. bpy.ops.export_scene.obj(
  2. filepath="",
  3. check_existing=True,
  4. axis_forward='-Z',
  5. axis_up='Y',
  6. filter_glob="*.obj;*.mtl",
  7. use_selection=False,
  8. use_animation=False,
  9. use_mesh_modifiers=True,
  10. use_edges=True,
  11. use_smooth_groups=False,
  12. use_smooth_groups_bitflags=False,
  13. use_normals=True,
  14. use_uvs=True,
  15. use_materials=True,
  16. use_triangles=False,
  17. use_nurbs=False,
  18. use_vertex_groups=False,
  19. use_blen_objects=True,
  20. group_by_object=False,
  21. group_by_material=False,
  22. keep_vertex_order=False,
  23. global_scale=1,
  24. path_mode='AUTO'
  25. )

2. 导出GLB:

  1. bpy.ops.export_scene.gltf(
  2. filepath = '',
  3. check_existing = True,
  4. export_import_convert_lighting_mode = 'SPEC',
  5. gltf_export_id = '',
  6. export_format = 'GLB',
  7. ui_tab = 'GENERAL', export_copyright = '',
  8. export_image_format = 'AUTO',
  9. export_image_add_webp = False,
  10. export_image_webp_fallback = False,
  11. export_texture_dir = '',
  12. export_jpeg_quality = 75,
  13. export_image_quality = 75,
  14. export_keep_originals = False,
  15. export_texcoords = True,
  16. export_normals = True,
  17. export_draco_mesh_compression_enable = False,
  18. export_draco_mesh_compression_level = 6,
  19. export_draco_position_quantization = 14,
  20. export_draco_normal_quantization = 10,
  21. export_draco_texcoord_quantization = 12,
  22. export_draco_color_quantization = 10,
  23. export_draco_generic_quantization = 12,
  24. export_tangents = False,
  25. export_materials = 'EXPORT',
  26. export_colors = True,
  27. export_attributes = False,
  28. use_mesh_edges = False,
  29. use_mesh_vertices = False,
  30. export_cameras = False,
  31. use_selection = False,
  32. use_visible = False,
  33. use_renderable = False,
  34. use_active_collection_with_nested = True,
  35. use_active_collection = False,
  36. use_active_scene = False, export_extras = False,
  37. export_yup = True,
  38. export_apply = False,
  39. export_animations = True,
  40. export_frame_range = False,
  41. export_frame_step = 1,
  42. export_force_sampling = True,
  43. export_animation_mode = 'ACTIONS',
  44. export_nla_strips_merged_animation_name = 'Animation',
  45. export_def_bones = False,
  46. export_hierarchy_flatten_bones = False,
  47. export_optimize_animation_size = True,
  48. export_optimize_animation_keep_anim_armature = True,
  49. export_optimize_animation_keep_anim_object = False,
  50. export_negative_frame = 'SLIDE',
  51. export_anim_slide_to_zero = False,
  52. export_bake_animation = False,
  53. export_anim_single_armature = True,
  54. export_reset_pose_bones = True,
  55. export_current_frame = False,
  56. export_rest_position_armature = True,
  57. export_anim_scene_split_object = True,
  58. export_skins = True, export_influence_nb = 4,
  59. export_all_influences = False,
  60. export_morph = True,
  61. export_morph_normal = True,
  62. export_morph_tangent = False,
  63. export_morph_animation = True,
  64. export_morph_reset_sk_data = True,
  65. export_lights = False, export_try_sparse_sk = True,
  66. export_try_omit_sparse_sk = False,
  67. export_gpu_instances = False,
  68. export_nla_strips = True,
  69. export_original_specular = False,
  70. will_save_settings = False, filter_glob = '*.glb'
  71. )

3. 细分模型:  

  1. file_loc = 'mm_frame.obj'
  2. imported_object = bpy.ops.import_scene.obj(filepath=file_loc)
  3. obj_object = bpy.context.selected_objects[0]
  4. bpy.ops.object.mode_set(mode="EDIT")
  5. bpy.ops.mesh.subdivide(number_cuts=2)
  6. bpy.ops.object.mode_set(mode="OBJECT")
  7. bpy.data.objects['Cube'].select_set(True)
  8. bpy.ops.object.delete()
  9. imported_object = bpy.ops.import_scene.obj(filepath=file_loc)
  10. obj = bpy.context.window.scene.objects[2]
  11. print(obj)
  12. bpy.context.view_layer.objects.active = obj
  13. bpy.ops.object.mode_set(mode="EDIT")
  14. bpy.ops.mesh.subdivide(number_cuts=2)
  15. bpy.ops.export_scene.obj(filepath="zetaxh.obj")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/332494
推荐阅读
相关标签
  

闽ICP备14008679号