当前位置: 首页 > news >正文

oeasy blender 016 晴天娃娃

blender016晴天娃娃

  • 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。晴天娃娃的制作_设置位置和旋转

开始

  • ​​配套视频​​
  • 上次我们
  • 深入理解了清场
  • 原来只是删除了对象
  • 并没有删除实际的
  • 网格
  • 灯光
  • 摄影机

  • 想做个晴天娃娃
  • 怎么做呢?🤔
制作三个球体
  • 白色的为头部
  • 黑色的为眼球

  • 眼球 参数
  • 一会儿要用

  • 如何使用代码生成?
代码生成头部
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() head = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "head"
  • 生成头部

生成左眼
import bpy bpy.ops.object.select_all(action="SELECT") # 选择所有物体 bpy.ops.object.delete() # 删除选定的物体 head = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3)
  • 效果

  • 准备上色

上色
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() head = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') mat.use_nodes = True color = (0, 0, 0, 1) mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat)
  • 效果

另一只眼睛
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() head = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') mat.use_nodes = True color = (0, 0, 0, 1) mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat) l_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "l_eye" bpy.context.object.location = (0.7, -0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) bpy.context.object.data.materials.append(mat)
  • 红眼睛的效果

  • 可以控制层次结构吗?
层次结构
  • 左右眼对象
  • 隶属于 脑袋
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() bpy.ops.mesh.primitive_uv_sphere_add() head = bpy.context.object bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') color = (0, 0, 0, 1) mat.use_nodes = True mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head l_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "l_eye" bpy.context.object.location = (0.7, -0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head
  • 效果

  • 左眼、右眼 两个对象
  • 成为 head 的字对象
增加一个身体
  • 添加一个圆锥体

  • 并修改参数

  • 将添加 身体圆锥 的操作
  • 转化为 代码
代码化
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() bpy.ops.mesh.primitive_uv_sphere_add() head = bpy.context.object bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') mat.use_nodes = True color = (0, 0, 0, 1) mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head l_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "l_eye" bpy.context.object.location = (0.7, -0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head bpy.ops.mesh.primitive_cone_add() body = bpy.context.object body.name = "body" body.location = (0,0,-1) body.scale = (1,1,2)
  • 可以加上 双手和双脚吗?
  • 可以带上 帽子 或者 眼镜吗?
  • 可以 添加 鼻子和耳朵吗?
  • 这个任务就交给你了
再封装
  • 现在场景中有两个对象
  • head
  • body

  • 可以把身体和头部
  • 整合成一个 角色 吗?
再封装
  • 把head、body
  • 封装进 character
import bpy bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() bpy.ops.mesh.primitive_uv_sphere_add() head = bpy.context.object bpy.context.object.name = "head" r_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "r_eye" bpy.context.object.location = (0.7, 0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') mat.use_nodes = True color = (0, 0, 0, 1) mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head l_eye = bpy.ops.mesh.primitive_uv_sphere_add() bpy.context.object.name = "l_eye" bpy.context.object.location = (0.7, -0.5, 0.3) bpy.context.object.scale = (0.3, 0.3, 0.3) bpy.context.object.data.materials.append(mat) bpy.context.object.parent = head bpy.ops.mesh.primitive_cone_add() body = bpy.context.object body.name = "body" body.location = (0,0,-1) body.scale = (1,1,2) character = bpy.data.objects.new("character", None) bpy.data.collections["Collection"].objects.link(character) head.parent = character body.parent = character
  • 制作成功

  • 可以封装成函数吗?
函数
import bpy def clear_scene(): bpy.ops.object.select_all(action="SELECT") bpy.ops.object.delete() def create_material(name, color): mat = bpy.data.materials.new(name) mat.use_nodes = True mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color return mat def create_eye(name, location, parent): bpy.ops.mesh.primitive_uv_sphere_add() eye = bpy.context.object eye.name = name eye.location = location eye.scale = (0.3, 0.3, 0.3) mat = bpy.data.materials.new('mat_eye') mat.use_nodes = True color = (0, 0, 0, 1) mat.node_tree.nodes["Principled BSDF"].inputs['Base Color'].default_value = color bpy.context.object.data.materials.append(mat) eye.parent = parent return eye def create_character(): # Create empty parent object character = bpy.data.objects.new("character", None) bpy.data.collections["Collection"].objects.link(character) # Create head bpy.ops.mesh.primitive_uv_sphere_add() head = bpy.context.object head.name = "head" head.parent = character # Create eyes create_eye("r_eye", (0.7, 0.5, 0.3), head) create_eye("l_eye", (0.7, -0.5, 0.3), head) # Create body bpy.ops.mesh.primitive_cone_add() body = bpy.context.object body.name = "body" body.location = (0, 0, -1) body.scale = (1, 1, 2) body.parent = character return character if __name__ == "__main__": clear_scene() create_character()
更多可能性
  • 双腿

双脚

帽子

翅膀

参数化生成毛毛虫

总结 🤔
  • 这次我们制作了
  • 晴天娃娃
  • 可以控制摄像机
  • 从不同角度拍摄他吗?
http://www.jsqmd.com/news/425016/

相关文章:

  • LangGraph4j 学习系列(5)-Hook勾子
  • 三傻排序
  • AWR性能报告
  • Gemini 3.0 配合向量引擎,这才是 2026 年程序员的“降维打击”神器!
  • 强化学习TRPO(信任区域策略优化)
  • 5G物理层控制信令深度解析:从PDCCH到PUCCH的核心架构与设计
  • 未对文件 D:\node-v24.14.0-win-x64\node-v24.14.0-win-x64\npm.ps1 进行数字签名
  • 神经网络的基本原理
  • nodejs+php+vue 基于JAVA的动漫周边商城的设计与实现
  • 回归本质:第一性原理思维
  • 微信小程序 停车场预约管理系统
  • 微信小程序 家庭健康管理系统
  • 斯特林数{1,2}{列,行}
  • FPGA实现线性调频LFM,zynq实现线性调频lfmzynq pl ps端都可以实现线性调频
  • 寒假作业(2月23号)
  • 星际之门:宇宙 (Stargate Universe, SGU)
  • 寒假作业(2月24号)
  • 用了这个代码单元测试生成器,摸鱼时间更多了
  • 寒假作业(2月27号)
  • 寒假作业(2月15号)
  • 寒假作业(2月28号)
  • 2026年杭州心理疏导机构推荐,温和疗愈缓解情绪压力 - 品牌鉴赏师
  • 基于节点电价分析的电网对电动汽车接纳能力评估模型研究
  • 寒假作业(2月20号)
  • 寒假作业(2月16号)
  • 寒假作业(2月21号)
  • 寒假作业(2月17号)
  • 寒假作业(2月11号)
  • 寒假作业(2月18号)
  • 寒假作业(2月22号)