x軸 回転 デューラー 4面  追加型 で 回転起動

 



import bpy

import urllib.request

from math import ceil


# 画像ファイルのパス

image_path = r"C:\aaa 2023 dondon\aaa2023いつもの\test_image\main-image デューラー メトロポリタン.jfif"


# 画像を開く

try:

    image = Image.open(image_path)

except:

    # ファイルが読み込めなかった場合は縦3横4の比でオブジェクトを作成する

    width, height = 4, 3

else:

    # 画像の幅と高さを取得する

    width, height = image.size


# サイズを計算する

if width > height:

    size = width

    ratio = height / width

else:

    size = height

    ratio = width / height


# 正方形を作成

bpy.ops.mesh.primitive_plane_add(size=size, enter_editmode=False, align='WORLD', location=(0,0,0))

square_obj = bpy.context.active_object


# オブジェクトに名前を付ける

square_obj.name = "狛犬 xy"


# アスペクト比を保ったままオブジェクトのスケールを変更する

if width > height:

    square_obj.scale[1] = ratio

else:

    square_obj.scale[0] = ratio


# マテリアルを作成

material = bpy.data.materials.new(name="ImageMaterial")

material.use_nodes = True

square_obj.data.materials.append(material)

square_obj.active_material = material


# テクスチャイメージを読み込む

tex_path = image_path

tex = bpy.data.images.load(tex_path)


# テクスチャノードを作成し、マテリアルに接続する

tex_node = material.node_tree.nodes.new("ShaderNodeTexImage")

tex_node.image = tex

tex_node.location = (-400, 0)

output_node = material.node_tree.nodes["Material Output"]

material.node_tree.links.new(tex_node.outputs[0], output_node.inputs[0])


# オブジェクトをXZ平面に回転する

square_obj.rotation_euler = (1.5708, 0, 0)





import math


# アニメーションのフレーム数を設定

animation_frames = 1000


# 回転角度を計算

rotation_angle = 2*math.pi  #2から変更


# アニメーションのキーフレームを設定

for i in range(animation_frames):

    bpy.context.scene.frame_set(i)

    square_obj.rotation_euler[0] = i/animation_frames * rotation_angle

    square_obj.keyframe_insert(data_path="rotation_euler", index=-1)


# 最終フレームにもキーフレームを設定

bpy.context.scene.frame_set(animation_frames)

square_obj.rotation_euler[0] = rotation_angle

square_obj.keyframe_insert(data_path="rotation_euler", index=-1)





ああああああああああああああああああああああああああ





import bpy

import urllib.request

from math import ceil


# 画像ファイルのパス

image_path = r"C:\aaa 2023 dondon\aaa2023いつもの\test_image\main-image デューラー メトロポリタン.jfif"


# 画像を開く

try:

    image = Image.open(image_path)

except:

    # ファイルが読み込めなかった場合は縦3横4の比でオブジェクトを作成する

    width, height = 4, 3

else:

    # 画像の幅と高さを取得する

    width, height = image.size


# サイズを計算する

if width > height:

    size = width

    ratio = height / width

else:

    size = height

    ratio = width / height


# 正方形を作成

bpy.ops.mesh.primitive_plane_add(size=size, enter_editmode=False, align='WORLD', location=(0,0,0))

square_obj = bpy.context.active_object


# オブジェクトに名前を付ける

square_obj.name = "狛犬 xy"


# アスペクト比を保ったままオブジェクトのスケールを変更する

if width > height:

    square_obj.scale[1] = ratio

else:

    square_obj.scale[0] = ratio


# マテリアルを作成

material = bpy.data.materials.new(name="ImageMaterial")

material.use_nodes = True

square_obj.data.materials.append(material)

square_obj.active_material = material


# テクスチャイメージを読み込む

tex_path = image_path

tex = bpy.data.images.load(tex_path)


# テクスチャノードを作成し、マテリアルに接続する

tex_node = material.node_tree.nodes.new("ShaderNodeTexImage")

tex_node.image = tex

tex_node.location = (-400, 0)

output_node = material.node_tree.nodes["Material Output"]

material.node_tree.links.new(tex_node.outputs[0], output_node.inputs[0])





import math


# アニメーションのフレーム数を設定

animation_frames = 1000


# 回転角度を計算

rotation_angle = 2*math.pi  #2から変更


# アニメーションのキーフレームを設定

for i in range(animation_frames):

    bpy.context.scene.frame_set(i)

    square_obj.rotation_euler[0] = i/animation_frames * rotation_angle

    square_obj.keyframe_insert(data_path="rotation_euler", index=-1)


# 最終フレームにもキーフレームを設定

bpy.context.scene.frame_set(animation_frames)

square_obj.rotation_euler[0] = rotation_angle

square_obj.keyframe_insert(data_path="rotation_euler", index=-1)




このブログの人気の投稿

基本の   線路レール

原型 球体36 xy 横 正方形 60x60 平面分布

原型 球体36 xz 縦 正方形 60x60 平面分布