Blender: 渲染图像和制作动画

问题描述 投票:1回答:1

我是Blender的新手,我对它的关键概念理解起来有点困难。我正在使用Blender 2.82并使用Python脚本。我的项目包括使用Python来做以下事情。

  1. 稍微移动物体
  2. 用相机1、相机2、相机3和相机4拍照。
  3. 重复进行。

我有一个脚本可以做到这一点。然而,我希望每次在动画的循环过程中改变对象(一个球体)的位置时都能保存下来,这样以后就可以看到我做了什么。当试图在我的循环中插入动画的关键帧时,好像我的球体没有移动。下面是我的代码。当我删除包括 frame_setkeyframe_insert我的球体移动,因为我可以看到我的渲染图像。我想我混淆了某种概念......任何帮助将被感激。我的目标是产生图像,我将获得从四个摄像头放置在周围的对象,这是移动的,以便模拟mocap系统.为什么插入一个关键帧改变所有的图像被渲染?

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个回答
1
投票

我不懂python,但你可以尝试手动做关键帧动画,并制作一个脚本,在一组关键帧后渲染图片(每当对象移动到一个新的位置)。

这并不难(我说的只是动画),只要按时间轴上播放动画按钮附近的圆圈按钮。这样就会开启自动键框,你只需要根据自己的需要,到所需的键框处移动物体即可。

© www.soinside.com 2019 - 2024. All rights reserved.