How to make a video of a PLY mesh from python script? I need to place the model in space and rotate it of 360 degrees on an axis.
Here is a ply example: http://220.127.116.11/3d/sodark.zip
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
You could use the add-ons linked to in the comments, but if you already have some form of script it's easy enough to plug in a small bit of code to get the same effect. Something like this. This adds a Camera (child) and an Empty (parent), then rotates the Empty on the Z-axis and keyframes each rotation, for
import math import bpy def add_cam(location, rotation): bpy.ops.object.camera_add(location=location, rotation=rotation) return bpy.context.active_object def add_empty(location): bpy.ops.object.empty_add(location=location) return bpy.context.active_object cam = add_cam(location=(0, -5, 0), rotation=(math.pi/2, 0, 0)) empty = add_empty(location=(0, 0, 0)) cam.parent = empty num_frames = 90 gamma = math.pi * 2 / num_frames for i in range(1, num_frames+1): empty.rotation_euler = gamma * i empty.keyframe_insert(data_path='rotation_euler', frame=i, index=-1)
You might perform some calculations to figure out based on the size and orientation of the Object, where to place the Empty and how far away to place the Camera and which Euler axis to rotate around.
Then you set your render resolution x, y and quality and output type, and
scene.frame_start, scene.frame_end. A smart approach is to render the sequence as separate frames first, using the
.png format. Then decide on the kind of final video format. A popular webformat is GIF or MP4. Blender can output a couple of video formats, but GIF is not one of them.
Blender can load a directory full of .png in the Video Sequence Editor (VSE) and render directly to a video video format/container (mp4, avi...etc). See Save rendered images in different formats
Unfortunately there's no feature that lets you convert a sequence of .png straight to GIF built in. But there are add-ons that use tools like ImageMagick and ffmpeg to do the conversion.