Skip to content

Latest commit

 

History

History
285 lines (233 loc) · 8.54 KB

644-2564913-飞机排成阵列_一字长蛇阵_人字_方阵_雁形之阵.sy.md

File metadata and controls

285 lines (233 loc) · 8.54 KB
show version enable_checker
step
1.0
true

python_blender

开始

  • 上次我们研究了
    • 物体的旋转
    • 有三个轴向
英文 中文 作用
heading 航向轴 转头
pitch 俯仰轴 点头
bank 横滚 歪头 盗梦空间特效
  • 可以让飞机排成一个阵列吗?

一字排开

import bpy
from math import pi

bpy.ops.object.select_all(action="SELECT") # 选择所有物体
bpy.ops.object.delete() # 删除选定的物体
planes = []
for n in range(5):
    c919 = bpy.data.objects.new("c919", None)
    bpy.data.collections["Collection"].objects.link(c919)
    bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=9)
    bpy.context.object.rotation_euler[0] = pi /2
    bpy.context.object.parent = c919
    bpy.ops.mesh.primitive_cube_add(size=2)
    bpy.context.object.name = "body"
    bpy.context.object.scale = (0.2,0.75,1)
    bpy.context.object.parent = c919
    bpy.context.object.rotation_euler[0] = - pi / 4
    bpy.context.object.location = (0, 5 ,1)
    bpy.context.object.parent = c919
    bpy.context.object.name = "tail1"
    bpy.ops.mesh.primitive_cube_add(size=2)
    bpy.context.object.scale = (1,0.5,0.25)
    bpy.context.object.location = (0, 5 ,1)
    bpy.context.object.parent = c919
    bpy.context.object.name = "tail2"
    bpy.ops.mesh.primitive_cube_add(size=2)
    bpy.context.object.scale = (5,1,0.25)
    bpy.context.object.location = (0, -1 ,0)
    bpy.context.object.parent = c919
    bpy.context.object.name = "wings"
    c919.location[0] = 10 * n
    planes.append(c919)
  • 效果

图片描述

  • 可以拍成一字长蛇阵吗?

修改位置

c919.location[1] = 10 * n
  • 结果

图片描述

  • 如果location选择第2个列表项
    • 会如何呢?

高度堆叠

c919.location[2] = 10 * n
  • 结果

图片描述

  • 可以把飞机列成一个方阵吗?

方阵

bpy.ops.object.delete() # 删除选定的物体
planes = []
for n1 in range(5):
    for n2 in range(5):
        c919 = bpy.data.objects.new("c919", None)
        bpy.data.collections["Collection"].objects.link(c919)
        bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=9)
        bpy.context.object.rotation_euler[0] = pi /2
        bpy.context.object.parent = c919
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.name = "body"
        bpy.context.object.scale = (0.2,0.75,1)
        bpy.context.object.parent = c919
        bpy.context.object.rotation_euler[0] = - pi / 4
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail1"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (1,0.5,0.25)
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail2"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (5,1,0.25)
        bpy.context.object.location = (0, -1 ,0)
        bpy.context.object.parent = c919
        bpy.context.object.name = "wings"
        c919.location[0] = 10 * n1
        c919.location[1] = 10 * n2
        planes.append(c919)
  • 效果

图片描述

  • 可以将方阵纵向叠加吗?

立体矩阵

import bpy
from math import pi

bpy.ops.object.select_all(action="SELECT") # 选择所有物体
bpy.ops.object.delete() # 删除选定的物体
planes = []
for n1 in range(5):
    for n2 in range(5):
        for n3 in range(5):
            c919 = bpy.data.objects.new("c919", None)
            bpy.data.collections["Collection"].objects.link(c919)
            bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=9)
            bpy.context.object.rotation_euler[0] = pi /2
            bpy.context.object.parent = c919
            bpy.ops.mesh.primitive_cube_add(size=2)
            bpy.context.object.name = "body"
            bpy.context.object.scale = (0.2,0.75,1)
            bpy.context.object.parent = c919
            bpy.context.object.rotation_euler[0] = - pi / 4
            bpy.context.object.location = (0, 5 ,1)
            bpy.context.object.parent = c919
            bpy.context.object.name = "tail1"
            bpy.ops.mesh.primitive_cube_add(size=2)
            bpy.context.object.scale = (1,0.5,0.25)
            bpy.context.object.location = (0, 5 ,1)
            bpy.context.object.parent = c919
            bpy.context.object.name = "tail2"
            bpy.ops.mesh.primitive_cube_add(size=2)
            bpy.context.object.scale = (5,1,0.25)
            bpy.context.object.location = (0, -1 ,0)
            bpy.context.object.parent = c919
            bpy.context.object.name = "wings"
            c919.location[0] = 10 * n1
            c919.location[1] = 10 * n2
            c919.location[2] = 10 * n3
            planes.append(c919)
  • 919列阵

图片描述

  • 可以列出什么阵型吗?

锥行之阵

import bpy
from math import pi

bpy.ops.object.select_all(action="SELECT") # 选择所有物体
bpy.ops.object.delete() # 删除选定的物体
planes = []
for n1 in range(5):
    for n2 in range(n1+1):
        c919 = bpy.data.objects.new("c919", None)
        bpy.data.collections["Collection"].objects.link(c919)
        bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=9)
        bpy.context.object.rotation_euler[0] = pi /2
        bpy.context.object.parent = c919
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.name = "body"
        bpy.context.object.scale = (0.2,0.75,1)
        bpy.context.object.parent = c919
        bpy.context.object.rotation_euler[0] = - pi / 4
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail1"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (1,0.5,0.25)
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail2"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (5,1,0.25)
        bpy.context.object.location = (0, -1 ,0)
        bpy.context.object.parent = c919
        bpy.context.object.name = "wings"
        c919.location[0] = -10 * n1
        c919.location[1] = -10 * n2
        planes.append(c919)
  • 锋芒所指
    • 无坚不摧

图片描述

调整位置

import bpy
from math import pi

bpy.ops.object.select_all(action="SELECT") # 选择所有物体
bpy.ops.object.delete() # 删除选定的物体
planes = []
for n1 in range(5):
    for n2 in range(n1+1):
        c919 = bpy.data.objects.new("c919", None)
        bpy.data.collections["Collection"].objects.link(c919)
        bpy.ops.mesh.primitive_cylinder_add(radius=1, depth=9)
        bpy.context.object.rotation_euler[0] = pi /2
        bpy.context.object.parent = c919
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.name = "body"
        bpy.context.object.scale = (0.2,0.75,1)
        bpy.context.object.parent = c919
        bpy.context.object.rotation_euler[0] = - pi / 4
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail1"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (1,0.5,0.25)
        bpy.context.object.location = (0, 5 ,1)
        bpy.context.object.parent = c919
        bpy.context.object.name = "tail2"
        bpy.ops.mesh.primitive_cube_add(size=2)
        bpy.context.object.scale = (5,1,0.25)
        bpy.context.object.location = (0, -1 ,0)
        bpy.context.object.parent = c919
        bpy.context.object.name = "wings"
        c919.location[0] = -10 * n1 + 5 * n2
        c919.location[1] = -10 * n2  
        planes.append(c919)
  • 中锋
    • 冲锋陷阵

图片描述

  • 还可以学习什么古阵法吗?

阵型

  • 古代阵型

图片描述

总结 🤔

  • 这次做了很多c919

    • 每个飞机都有自己的机身、机翼...
  • 如何修改物体的颜色呢?🤔

图片描述

  • 我们下次再说!👋