このスクリプトは、z=0平面上にある半径30の円周の中心を放出位置として、36個の球体を放出します。また、放出された球体は、z=0平面上の円周上を等速で移動します。ただし、放出する球体の速度は、放出位置から円周の中心までの距離に反比例するように決定されます。また、アニメーションのフレーム数は1000フレームに設定されています。
import bpy
import math
from mathutils import Vector
# Set initial locations
radius = 30
initial_locations = []
for i in range(36):
angle = math.radians(i * 10)
x = radius * math.cos(angle)
y = radius * math.sin(angle)
z = 0
initial_locations.append(Vector((x, y, z)))
# Set sphere radius and segments
sphere_radius = 1
sphere_segments = 32
# Calculate speeds based on initial distances from target
chousei_kijyun = 30
distances = [loc.length for loc in initial_locations]
speeds = [0.1 * (chousei_kijyun / distance) if distance > 0 else 0 for distance in distances]
# Create sphere objects and set locations
for i, initial_location in enumerate(initial_locations):
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, segments=sphere_segments)
sphere = bpy.context.object
sphere.location = initial_location
sphere.name = f"Sphere_{i}"
# Set animation keyframes
last_frame = 1000
for frame in range(last_frame+1):
distance = (initial_location - Vector((0, 0, 0))).length
if distance > 0.01:
direction = (Vector((0, 0, 0)) - initial_location).normalized()
sphere.location += direction * min(speeds[i], distance)
sphere.keyframe_insert(data_path="location", frame=frame)
# Function to set the number of frames
def set_frame_range(start_frame, end_frame):
bpy.context.scene.frame_start = start_frame
bpy.context.scene.frame_end = end_frame
# Example: set the number of frames to 1000
set_frame_range(1, 1000)
y=0 平面だ
import bpy
import math
from mathutils import Vector
# Set initial locations
initial_locations = []
for i in range(0, 360, 10):
x = 30 * math.cos(math.radians(i))
y = 0
z = 30 * math.sin(math.radians(i))
initial_locations.append(Vector((x, y, z)) + Vector((0, 0, 0)))
# Set sphere radius and segments
sphere_radius = 1
sphere_segments = 32
# Calculate speeds based on initial distances from target
chousei_kijyun = 30
distances = [loc.length for loc in initial_locations]
speeds = [0.1 * (chousei_kijyun / distance) if distance > 0 else 0 for distance in distances]
# Create sphere objects and set locations
for i, initial_location in enumerate(initial_locations):
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, segments=sphere_segments)
sphere = bpy.context.object
sphere.location = initial_location
sphere.name = f"Sphere_{i}"
# Set animation keyframes
last_frame = 1000
for frame in range(last_frame+1):
distance = (initial_location - Vector((0, 0, 0))).length
if distance > 0.01:
direction = (Vector((0, 0, 0)) - initial_location).normalized()
sphere.location += direction * min(speeds[i], distance)
sphere.keyframe_insert(data_path="location", frame=frame)
# Function to set the number of frames
def set_frame_range(start_frame, end_frame):
bpy.context.scene.frame_start = start_frame
bpy.context.scene.frame_end = end_frame
# Example: set the number of frames to 1000
set_frame_range(1, 1000)
z=0平面
import bpy
import math
from mathutils import Vector
# Set initial locations
radius = 30
initial_locations = []
for i in range(36):
angle = math.radians(i * 10)
x = radius * math.cos(angle)
y = radius * math.sin(angle)
z = 0
initial_locations.append(Vector((x, y, z)))
# Set sphere radius and segments
sphere_radius = 1
sphere_segments = 32
# Calculate speeds based on initial distances from target
chousei_kijyun = 30
distances = [loc.length for loc in initial_locations]
speeds = [0.1 * (chousei_kijyun / distance) if distance > 0 else 0 for distance in distances]
# Create sphere objects and set locations
for i, initial_location in enumerate(initial_locations):
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, segments=sphere_segments)
sphere = bpy.context.object
sphere.location = initial_location
sphere.name = f"Sphere_{i}"
# Set animation keyframes
last_frame = 1000
for frame in range(last_frame+1):
distance = (initial_location - Vector((0, 0, 0))).length
if distance > 0.01:
direction = (Vector((0, 0, 0)) - initial_location).normalized()
sphere.location += direction * min(speeds[i], distance)
sphere.keyframe_insert(data_path="location", frame=frame)
# Function to set the number of frames
def set_frame_range(start_frame, end_frame):
bpy.context.scene.frame_start = start_frame
bpy.context.scene.frame_end = end_frame
# Example: set the number of frames to 1000
set_frame_range(1, 1000)
放出点を (0, -30, 0)、初期位置の y 座標を -60 に設定して、円周が y = -30、z = 0 平面に沿うように変更できます。
平行移動重ね y軸方向を動く 円周 収縮
import bpy
import math
from mathutils import Vector
# Set initial locations
initial_locations = []
for i in range(0, 360, 10):
x = 30 * math.cos(math.radians(i))
y = -60
z = 30 * math.sin(math.radians(i))
initial_locations.append(Vector((x, y, z)))
# Set sphere radius and segments
sphere_radius = 1
sphere_segments = 32
# Calculate speeds based on initial distances from target
chousei_kijyun = 30
distances = [(loc - Vector((0, -30, 0))).length for loc in initial_locations]
speeds = [0.1 * (chousei_kijyun / distance) if distance > 0 else 0 for distance in distances]
# Create sphere objects and set locations
for i, initial_location in enumerate(initial_locations):
bpy.ops.mesh.primitive_uv_sphere_add(radius=sphere_radius, segments=sphere_segments)
sphere = bpy.context.object
sphere.location = Vector((initial_location.x, -30, initial_location.z))
sphere.name = f"Sphere_{i}"
# Set animation keyframes
last_frame = 1000
for frame in range(last_frame+1):
distance = (initial_location - Vector((0, -30, 0))).length
if distance > 0.01:
direction = (Vector((0, -30, 0)) - initial_location).normalized()
sphere.location += direction * min(speeds[i], distance)
sphere.keyframe_insert(data_path="location", frame=frame)
# Function to set the number of frames
def set_frame_range(start_frame, end_frame):
bpy.context.scene.frame_start = start_frame
bpy.context.scene.frame_end = end_frame
# Example: set the number of frames to 1000
set_frame_range(1, 1000)