2023年4月8日土曜日

再生アニメ ファイルからでも 動く 原型 らしい

 


import bpy

from mathutils import Vector

import math


# Set target location

target_location = Vector((0, 0, 60))


# Set initial location

initial_location = Vector((60, 0, 0))


# Set sphere properties

radius = 2


# Calculate the distance between the target location and the initial location

distance = (target_location - initial_location).length


# Calculate the speed of the sphere for each frame

speeds = [0.0] * 600

for i in range(600):

    if i < 300:

        speeds[i] = 0.2 * (i / 300)

    else:

        speeds[i] = 0.2 + 0.8 * ((i - 300) / 300)


# Create sphere object and set location

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, location=initial_location)

sphere = bpy.context.object


# Set animation keyframes

for frame in range(600):

    # Calculate the direction from the sphere's current location to the target location

    direction = (target_location - sphere.location).normalized()

    

    # Calculate the distance between the sphere's current location and the target location

    distance = (target_location - sphere.location).length

    

    # Move the sphere based on its speed and direction

    sphere.location += direction * speeds[frame] * distance

    

    # Set keyframe for sphere location

    sphere.keyframe_insert(data_path="location", frame=frame)


改良中 y=-30 中心 円周への球体36個

できた y= -30 中心で z=0平面移動  import bpy import math zion_collection_name = "線路レール 観察者" # コレクションを作成する col = bpy.data.collections.new(zio...