import math
import random
import bpy
big_sphere_radius = 3.0
big_sphere_location = (0, 0, 0)
big_sphere_name = "Big Sphere"
random_ball_count = 2
random_ball_radius = 0.1
random_ball_name = "random_ball"
segment_ball_count = 9
segment_ball_radius = 0.05
segment_ball_name = "senbun_ball"
# 大きな球体を作成
bpy.ops.mesh.primitive_uv_sphere_add(radius=big_sphere_radius, location=big_sphere_location, enter_editmode=False)
bpy.context.object.name = big_sphere_name
# ランダムな小さな球体を作成
for i in range(random_ball_count):
theta = random.uniform(0, 2 * math.pi)
phi = random.uniform(0, math.pi)
x = big_sphere_radius * math.sin(phi) * math.cos(theta) + big_sphere_location[0]
y = big_sphere_radius * math.sin(phi) * math.sin(theta) + big_sphere_location[1]
z = big_sphere_radius * math.cos(phi) + big_sphere_location[2]
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=random_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{random_ball_name}{i}"
# ランダムに2つの球体を選び、選択状態にする
random_balls = [obj for obj in bpy.data.objects if obj.name.startswith(random_ball_name)]
selected_spheres = random.sample(random_balls, 2)
# 選択した球体をショッキングピンク色にする
pink_material = bpy.data.materials.new(name="Pink")
pink_material.diffuse_color = (1, 0, 1, 1)
for obj in selected_spheres:
obj.active_material = pink_material
# 選ばれた2つの球体の間に、9つの小さな球体を作成
x1, y1, z1 = selected_spheres[0].location
x2, y2, z2 = selected_spheres[1].location
for i in range(segment_ball_count):
t = (i + 1) / (segment_ball_count + 1)
x = (1 - t) * x1 + t * x2
y = (1 - t) * y1 + t * y2
z = (1 - t) * z1 + t * z2
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=segment_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{segment_ball_name}{i}"
bpy.context.object.active_material = bpy.data.materials.new(f"Material_{i}")
bpy.context.object.active_material.diffuse_color = (1, 0, 0, 1) # 赤色
import math
import random
import bpy
big_sphere_radius = 3.0
big_sphere_location = (0, 0, 0)
big_sphere_name = "Big Sphere"
random_ball_count = 2
random_ball_radius = 0.1
random_ball_name = "random_ball"
segment_ball_count = 9
segment_ball_radius = 0.05
segment_ball_name = "senbun_ball"
# 大きな球体を作成
bpy.ops.mesh.primitive_uv_sphere_add(radius=big_sphere_radius, location=big_sphere_location, enter_editmode=False)
bpy.context.object.name = big_sphere_name
# ランダムな小さな球体を作成
for i in range(random_ball_count):
theta = random.uniform(0, 2 * math.pi)
phi = random.uniform(0, math.pi)
x = big_sphere_radius * math.sin(phi) * math.cos(theta) + big_sphere_location[0]
y = big_sphere_radius * math.sin(phi) * math.sin(theta) + big_sphere_location[1]
z = big_sphere_radius * math.cos(phi) + big_sphere_location[2]
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=random_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{random_ball_name}{i}"
# ランダムに2つの球体を選び、選択状態にする
random_balls = [obj for obj in bpy.data.objects if obj.name.startswith(random_ball_name)]
selected_spheres = random.sample(random_balls, 2)
# 選択した球体をショッキングピンク色にする
for obj in selected_spheres:
obj.active_material.diffuse_color = (1, 0, 1, 1)
# 選ばれた2つの球体の間に、9つの小さな球体を作成
x1, y1, z1 = selected_spheres[0].location
x2, y2, z2 = selected_spheres[1].location
for i in range(segment_ball_count):
t = (i + 1) / (segment_ball_count + 1)
x = (1 - t) * x1 + t * x2
y = (1 - t) * y1 + t * y2
z = (1 - t) * z1 + t * z2
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=segment_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{segment_ball_name}{i}"
bpy.context.object.active_material = bpy.data.materials.new(f"Material_{i}")
bpy.context.object.active_material.diffuse_color = (1, 0, 0, 1) # 赤色のマテリアルを設定
# 選択した球体を赤色にする
for obj in selected_spheres:
obj.active_material.diffuse_color = (1, 0, 0, 1)
# 選択した球体を赤色にする
for obj in selected_spheres:
obj.active_material.diffuse_color = (1, 0, 1, 1)
import math
import random
import bpy
big_sphere_radius = 3.0
big_sphere_location = (0, 0, 0)
big_sphere_name = "Big Sphere"
random_ball_count = 2
random_ball_radius = 0.1
random_ball_name = "random_ball"
segment_ball_count = 9
segment_ball_radius = 0.05
segment_ball_name = "senbun_ball"
# 大きな球体を作成
bpy.ops.mesh.primitive_uv_sphere_add(radius=big_sphere_radius, location=big_sphere_location, enter_editmode=False)
bpy.context.object.name = big_sphere_name
# ランダムな小さな球体を作成
for i in range(random_ball_count):
theta = random.uniform(0, 2 * math.pi)
phi = random.uniform(0, math.pi)
x = big_sphere_radius * math.sin(phi) * math.cos(theta) + big_sphere_location[0]
y = big_sphere_radius * math.sin(phi) * math.sin(theta) + big_sphere_location[1]
z = big_sphere_radius * math.cos(phi) + big_sphere_location[2]
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=random_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{random_ball_name}{i}"
# ランダムに2つの球体を選び、選択状態にする
random_balls = [obj for obj in bpy.data.objects if obj.name.startswith(random_ball_name)]
selected_spheres = random.sample(random_balls, 2)
# 選ばれた2つの球体の間に、9つの小さな球体を作成
x1 = selected_spheres[0].location[0]
y1 = selected_spheres[0].location[1]
z1 = selected_spheres[0].location[2]
x2 = selected_spheres[1].location[0]
y2 = selected_spheres[1].location[1]
z2 = selected_spheres[1].location[2]
for i in range(segment_ball_count):
t = (i + 1) / (segment_ball_count + 1)
x = (1 - t) * x1 + t * x2
y = (1 - t) * y1 + t * y2
z = (1 - t) * z1 + t * z2
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=segment_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{segment_ball_name}{i}"
import math
import random
import bpy
big_sphere_radius = 3.0
big_sphere_location = (0, 0, 0)
big_sphere_name = "Big Sphere"
random_ball_count = 2
random_ball_radius = 0.1
random_ball_name = "random_ball"
segment_ball_count = 9
segment_ball_radius = 0.05
segment_ball_name = "senbun_ball"
# 大きな球体を作成
bpy.ops.mesh.primitive_uv_sphere_add(radius=big_sphere_radius, location=big_sphere_location, enter_editmode=False)
bpy.context.object.name = big_sphere_name
# ランダムな小さな球体を作成
for i in range(random_ball_count):
theta = random.uniform(0, 2 * math.pi)
phi = random.uniform(0, math.pi)
x = big_sphere_radius * math.sin(phi) * math.cos(theta) + big_sphere_location[0]
y = big_sphere_radius * math.sin(phi) * math.sin(theta) + big_sphere_location[1]
z = big_sphere_radius * math.cos(phi) + big_sphere_location[2]
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=random_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{random_ball_name}{i}"
# ランダムに2つの球体を選び、選択状態にする
random_balls = [obj for obj in bpy.data.objects if obj.name.startswith(random_ball_name)]
selected_spheres = random.sample(random_balls, 2)
# 選ばれた2つの球体の間に、9つの小さな球体を作成
x1 = selected_spheres[0].location[0]
y1 = selected_spheres[0].location[1]
z1 = selected_spheres[0].location[2]
x2 = selected_spheres[1].location[0]
y2 = selected_spheres[1].location[1]
z2 = selected_spheres[1].location[2]
for i in range(segment_ball_count):
t = (i + 1) / (segment_ball_count + 1)
x = (1 - t) * x1 + t * x2
y = (1 - t) * y1 + t * y2
z = (1 - t) * z1 + t * z2
loc = (x, y, z)
bpy.ops.mesh.primitive_uv_sphere_add(radius=segment_ball_radius, location=loc, enter_editmode=False)
bpy.context.object.name = f"{segment_ball_name}{i}"