【问题标题】:Blender: Rendering images and producing an animationBlender:渲染图像并制作动画
【发布时间】:2020-08-19 10:40:44
【问题描述】:

我是 Blender 的新手,我很难理解它的关键概念。我正在使用 Blender 2.82 并使用 Python 脚本。我的项目包括使用 Python 执行以下操作:

  1. 稍微移动对象。
  2. 使用相机 1、相机 2、相机 3 和相机 4 拍照。
  3. 重复。

我有一个脚本可以做到这一点。但是,我想在动画循环期间每次更改对象(球体)的位置时保存它,以便以后可以看到我做了什么。当尝试在我的循环中插入动画关键帧时,我的球体似乎没有移动。下面是我的代码。当我删除包含frame_set 和keyframe_insert 的行时,我的球体移动,正如我从渲染图像中看到的那样。我想我混淆了某种概念……任何帮助将不胜感激。这样做的目的是生成我将从放置在一个正在移动的对象周围的四个摄像机获得的图像,以模拟一个动作捕捉系统。 为什么插入关键帧会改变所有正在渲染的图像?

import bpy, bgl, blf,sys
import numpy as np
from bpy import data, ops, props, types, context

cameraNames=''

# Loop all command line arguments and try to find "cameras=east" or similar
for arg in sys.argv:
    words=arg.split('=')
    if ( words[0] == 'cameras'):
     cameraNames = words[1]

sceneKey = bpy.data.scenes.keys()[0]

# Loop all objects and try to find Cameras
bpy.data.scenes[sceneKey].render.image_settings.file_format = 'JPEG'
bpy.data.scenes[sceneKey].cycles.max_bounces=12
bpy.data.scenes[sceneKey].render.tile_x=8
bpy.data.scenes[sceneKey].render.tile_y=8
bpy.data.scenes[sceneKey].cycles.samples = 16
bpy.data.scenes[sceneKey].cycles.caustics_reflective = False
bpy.data.scenes[sceneKey].cycles.caustics_refractive = False

bpy.data.objects['Sphere'].location=[1,1,1] 
frame_num=0
for i in range(0,2): #nframes
    bpy.context.scene.frame_set(frame_num)
    for obj in bpy.data.objects:
        # Find cameras that match cameraNames
        if ( obj.type =='CAMERA') and ( cameraNames == '' or obj.name.find(cameraNames) != -1) :

          # Set Scenes camera and output filename
            bpy.data.scenes[sceneKey].camera = obj
            bpy.data.scenes[sceneKey].render.filepath = '//'+obj.name+"_"+str(i) 

          # Render Scene and store the scene
            bpy.ops.render.render( write_still=True )

    bpy.data.objects['Sphere'].keyframe_insert(data_path="location",index=-1)
    frame_num+=1
    bpy.data.objects['Sphere'].location=[2,2,1]

【问题讨论】:

    标签: python animation render blender keyframe


    【解决方案1】:

    我对python一无所知,但你可以尝试手动制作关键帧动画并制作一个脚本,该脚本将在一组关键帧之后渲染图片(每当对象移动到新位置时)

    这不是太难(我说的只是动画),只需按时间轴上播放动画按钮附近的圆圈按钮即可。这将打开自动关键帧,您只需转到所需的关键帧并根据需要移动对象。

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 2016-05-05
      • 2011-07-09
      • 2016-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      相关资源
      最近更新 更多