3d-modeling
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese3d-modeling
3d-modeling
Purpose
用途
This skill provides tools for creating, editing, and optimizing 3D models using Blender, specifically tailored for AR/VR applications. It focuses on generating assets like meshes and textures that integrate seamlessly into virtual environments.
本Skill提供了使用Blender创建、编辑和优化3D模型的工具,专门适配AR/VR应用场景,重点关注生成可无缝集成到虚拟环境的网格、纹理等资产。
When to Use
适用场景
Use this skill when developing AR/VR prototypes that require custom 3D models, such as designing interactive objects for VR simulations or overlaying digital assets in AR scenes. Apply it in workflows involving asset creation, modification, or export for platforms like Unity or Oculus.
当你开发需要自定义3D模型的AR/VR原型时可以使用本Skill,例如为VR仿真设计交互对象,或者在AR场景中叠加数字资产。也可在面向Unity、Oculus等平台的资产创建、修改、导出工作流中使用。
Key Capabilities
核心能力
- Create and manipulate 3D meshes using Blender's Python API, e.g., generating a cube with .
bpy.ops.mesh.primitive_cube_add() - Apply materials and textures for AR/VR realism, such as using to add shaders.
bpy.data.materials.new() - Render scenes optimized for AR/VR, including exporting to GLTF format with embedded textures via .
bpy.ops.export_scene.gltf() - Perform batch operations via CLI for automation, like processing multiple files.
- Integrate with AR/VR tools by exporting models that support real-time rendering, such as low-poly meshes for mobile VR.
- 借助Blender的Python API创建和操作3D网格,例如使用生成立方体。
bpy.ops.mesh.primitive_cube_add() - 应用材质和纹理提升AR/VR真实感,例如使用添加着色器。
bpy.data.materials.new() - 渲染适配AR/VR的优化场景,包括通过导出带嵌入纹理的GLTF格式文件。
bpy.ops.export_scene.gltf() - 通过CLI执行批量操作实现自动化,例如处理多个文件。
- 导出支持实时渲染的模型(例如面向移动端VR的低多边形网格),实现与AR/VR工具的集成。
Usage Patterns
使用模式
Follow these patterns to leverage the skill effectively. Always run Blender in a compatible environment with Python 3.7+ installed.
-
Basic Model Creation: Start by launching Blender from the command line and scripting a simple object. Use this for quick AR prototypes.
- Example: Create a cube and export it as GLTF for AR integration.
import bpy bpy.ops.mesh.primitive_cube_add(size=2, location=(0,0,0)) bpy.ops.export_scene.gltf(filepath="cube.gltf")
- Example: Create a cube and export it as GLTF for AR integration.
-
Model Editing for VR: Import an existing model, apply modifications, and optimize for VR performance.
- Example: Load a mesh, reduce polygons, and export for VR headset compatibility.
import bpy bpy.ops.import_scene.obj(filepath="model.obj") bpy.ops.object.modifier_add(type='DECIMATE') bpy.ops.export_scene.gltf(filepath="optimized_model.gltf", export_format='GLTF_SEPARATE')
- Example: Load a mesh, reduce polygons, and export for VR headset compatibility.
For complex tasks, wrap these in scripts and run via Blender's CLI to automate AR/VR asset pipelines.
遵循以下模式可以高效使用本Skill,请务必在安装了Python 3.7+的兼容环境中运行Blender。
-
基础模型创建: 从命令行启动Blender,编写脚本生成简单对象,可用于快速AR原型开发。
- 示例:创建立方体并导出为GLTF格式用于AR集成。
import bpy bpy.ops.mesh.primitive_cube_add(size=2, location=(0,0,0)) bpy.ops.export_scene.gltf(filepath="cube.gltf")
- 示例:创建立方体并导出为GLTF格式用于AR集成。
-
面向VR的模型编辑: 导入现有模型,进行修改并针对VR性能做优化。
- 示例:加载网格、减少多边形数量并导出为适配VR头显的格式。
import bpy bpy.ops.import_scene.obj(filepath="model.obj") bpy.ops.object.modifier_add(type='DECIMATE') bpy.ops.export_scene.gltf(filepath="optimized_model.gltf", export_format='GLTF_SEPARATE')
- 示例:加载网格、减少多边形数量并导出为适配VR头显的格式。
对于复杂任务,可以将这些操作封装到脚本中,通过Blender的CLI运行,实现AR/VR资产pipeline的自动化。
Common Commands/API
常用命令/API
Use Blender's CLI and Python API for core operations. Specify exact flags for efficiency.
-
CLI Commands: Run scripts in background mode.
- : Loads a file, runs a script, and renders an image for AR previews.
blender --background input.blend --python script.py --render-output output.png - : Executes a script on a blend file and outputs renders; use
blender -b file.blend -P script.py -F PNG -o //render_for format like PNG for VR thumbnails.-F
-
Python API Snippets: Access viamodule in Blender scripts.
bpy- Snippet for adding a material:
mat = bpy.data.materials.new("AR_Material") mat.diffuse_color = (1, 0, 0, 1) # Red color for AR visibility - Snippet for mesh manipulation:
obj = bpy.context.active_object obj.scale = (1.5, 1.5, 1.5) # Scale object for VR fitting
- Snippet for adding a material:
Config formats: Use JSON-like structures in Blender files (.blend) for custom properties, e.g., add via . For exports, specify GLTF options in scripts, like for metadata.
bpy.types.Scene.my_prop = "value"export_extras=True使用Blender的CLI和Python API执行核心操作,指定精确的参数可以提升效率。
-
CLI命令: 在后台模式运行脚本。
- : 加载文件、运行脚本并渲染图片用于AR预览。
blender --background input.blend --python script.py --render-output output.png - : 对blend文件执行脚本并输出渲染结果;使用
blender -b file.blend -P script.py -F PNG -o //render_指定输出格式,例如PNG格式可作为VR缩略图。-F
-
Python API片段: 在Blender脚本中通过模块调用。
bpy- 添加材质的代码片段:
mat = bpy.data.materials.new("AR_Material") mat.diffuse_color = (1, 0, 0, 1) # 红色,提升AR可见性 - 网格操作的代码片段:
obj = bpy.context.active_object obj.scale = (1.5, 1.5, 1.5) # 缩放对象以适配VR尺寸
- 添加材质的代码片段:
配置格式:在Blender文件(.blend)中使用类JSON结构存储自定义属性,例如通过添加属性。导出时可以在脚本中指定GLTF选项,例如设置导出元数据。
bpy.types.Scene.my_prop = "value"export_extras=TrueIntegration Notes
集成说明
Integrate this skill with AR/VR frameworks by exporting models in compatible formats. For external services (e.g., cloud rendering), use environment variables for authentication, such as if accessing paid APIs, though Blender itself is local. Pattern: Set in scripts before API calls. Ensure dependencies like Python packages (e.g., ) are installed via if using external editors. For AR/VR platforms, import GLTF files directly into Unity or Unreal, matching coordinate systems (e.g., Z-up for Blender).
$BLENDER_API_KEYexport os.environ['BLENDER_API_KEY'] = 'your_key'bpypip install bpy导出兼容格式的模型即可将本Skill与AR/VR框架集成。对于外部服务(例如云渲染),可以使用环境变量进行身份验证,例如如果访问付费API可使用,不过Blender本身是本地工具。使用模式:在调用API前在脚本中设置。如果使用外部编辑器,需要通过安装等Python包依赖。对于AR/VR平台,可以直接将GLTF文件导入Unity或Unreal,注意对齐坐标系(例如Blender使用Z轴向上)。
$BLENDER_API_KEYexport os.environ['BLENDER_API_KEY'] = 'your_key'pip install bpybpyError Handling
错误处理
Anticipate and handle errors in scripts to maintain AR/VR workflow reliability. Check for file existence before imports: Use . For API failures, like failed exports, catch exceptions:
if not bpy.data.filepath: raise ValueError("File not found")try:
bpy.ops.export_scene.gltf(filepath="output.gltf")
except RuntimeError as e:
print(f"Export failed: {e}") # Log and retry or fallbackCommon issues: Invalid paths (use absolute paths), memory errors on large models (optimize with decimate modifier first), or version mismatches (ensure Blender 2.8+). Always test scripts in a non-destructive environment.
在脚本中提前预判和处理错误可以保证AR/VR工作流的稳定性。导入前检查文件是否存在:使用。对于导出失败等API错误,可以捕获异常:
if not bpy.data.filepath: raise ValueError("File not found")try:
bpy.ops.export_scene.gltf(filepath="output.gltf")
except RuntimeError as e:
print(f"Export failed: {e}") # 记录日志并重试或使用降级方案常见问题:路径无效(请使用绝对路径)、大模型导致内存错误(先使用精简修改器优化)、版本不匹配(请使用Blender 2.8+版本)。请务必在非破坏性环境中测试脚本。
Graph Relationships
关联关系
- Belongs to cluster: ar-vr
- Related tags: 3d-modeling, blender, ar-vr
- Connected skills: rendering (for post-processing AR/VR assets), mesh-optimization (for performance in VR)
- 所属集群:ar-vr
- 相关标签:3d-modeling, blender, ar-vr
- 关联技能:渲染(用于AR/VR资产后处理)、网格优化(用于提升VR场景性能)