できた y= -30 中心で z=0平面移動
import bpy
import math
zion_collection_name = "線路レール 観察者"
# コレクションを作成する
col = bpy.data.collections.new(zion_collection_name)
bpy.context.scene.collection.children.link(col)
import bpy
import math
zion_collection_name = "土台"
# コレクションを作成する
col = bpy.data.collections.new(zion_collection_name)
bpy.context.scene.collection.children.link(col)
boolean
https://shion-no-yahiro.com/boolean/
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))) #idou
# 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 = + Vector((0, -30, 0)) # move the entire scene down by 30 units
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軸 平行
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))) # -30 にしないと移動
# 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 + Vector((0, -30, 0)) # move the entire scene down by 30 units
sphere.name = f"Sphere_{i}"
# Set animation keyframes
last_frame = 2000
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)