失敗のか ? 十字 額縁 回転と 平行移動



# 十字 額縁 平行移動 縦設置 xz平面


import bpy

import urllib.request

from math import ceil

import math


# 画像ファイルのパス

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

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

animation_frames = 1000

# 回転角度を計算

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


# 画像を開く

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 = "xz 額縁"


# オブジェクトを指定した位置に移動する

square_obj.location = (0, 0, 0)



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

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])


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

animation_frames = 1000


# 回転角度を計算

rotation_angle = 2*math.pi


# アニメーション開始前に90度回転する

#square_obj.rotation_euler[0] = math.radians(90)


# 開始位置を設定

#square_obj.rotation_euler[0] = rotation_angle + (math.pi/2) # 開始時に90度回転

square_obj.rotation_euler[0] = rotation_angle



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

for i in range(animation_frames+1):

    bpy.context.scene.frame_set(i)

    x_pos = i / 10  # x軸に0.1進む

    y_rot = (i/animation_frames * rotation_angle) - rotation_angle  # 回転角度を設定

    square_obj.location.x = x_pos

    square_obj.rotation_euler[0] = math.radians(90)  # 90度回転

    square_obj.rotation_euler[1] = y_rot  # y軸回転




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

bpy.context.scene.frame_set(animation_frames)

square_obj.rotation_euler[0] = rotation_angle  + (math.pi/2)

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






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

square_obj.rotation_euler = (1.5708, 0, 0)



# コレクションは 先に作って おく 

# オブジェクトのコレクションへの追加は 手動  




import bpy

# コレクションを作成

collection_name = "十字 額縁"

if collection_name not in bpy.data.collections:

    zionad_collection = bpy.data.collections.new(collection_name)

    bpy.context.scene.collection.children.link(zionad_collection)

else:

    zionad_collection = bpy.data.collections[collection_name]


#あああああああああああああああああああああ 


import bpy


# カメラの位置を変更する

bpy.data.objects['Camera'].location = (0, 0, 60)


# ライトの位置を変更する

bpy.data.objects['Light'].location = (0, 0, 65)



#あああああああああああああああああああああ 

# フレームレンジを設定する


 

import bpy


def set_frame_range(start_frame, end_frame):

    bpy.context.scene.frame_start = start_frame

    bpy.context.scene.frame_end = end_frame


# メイン関数

def main():

    # フレームレンジを設定する

    set_frame_range(1, 1000)


# スクリプトを実行する

if __name__ == "__main__":

    main()



#あああああああああああああああああああああ 


# 十字 額縁 縦設置 xz平面


import bpy

import urllib.request

from math import ceil

import math


# 画像ファイルのパス

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

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

animation_frames = 1000

# 回転角度を計算

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


# 画像を開く

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 = "xz 額縁"


# オブジェクトを指定した位置に移動する

square_obj.location = (0, 0, 0)



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

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])


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

animation_frames = 1000


# 回転角度を計算

rotation_angle = 2*math.pi


# アニメーション開始前に90度回転する

#square_obj.rotation_euler[0] = math.radians(90)


# 開始位置を設定

#square_obj.rotation_euler[0] = rotation_angle + (math.pi/2) # 開始時に90度回転

square_obj.rotation_euler[0] = rotation_angle

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

for i in range(animation_frames+1):

    bpy.context.scene.frame_set(i)

    square_obj.rotation_euler[0] = (i/animation_frames * rotation_angle) - rotation_angle  + (math.pi/2)

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



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

bpy.context.scene.frame_set(animation_frames)

square_obj.rotation_euler[0] = rotation_angle  + (math.pi/2)

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


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

square_obj.rotation_euler = (1.5708, 0, 0)





#ノーマル回転あああああああああ

# 十字 額縁 横設置 xy平面


import bpy

import urllib.request

from math import ceil

import math


# 画像ファイルのパス

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

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

animation_frames = 1000

# 回転角度を計算

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


# 画像を開く

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 額縁"


# オブジェクトを指定した位置に移動する

square_obj.location = (0, 0, 0)



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

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])


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

animation_frames = 1000


# 回転角度を計算

rotation_angle = 2*math.pi


# アニメーション開始前に90度回転する

#square_obj.rotation_euler[0] = math.radians(90)


# 開始位置を設定

#square_obj.rotation_euler[0] = rotation_angle + (math.pi/2) # 開始時に90度回転

square_obj.rotation_euler[0] = rotation_angle

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

for i in range(animation_frames+1):

    bpy.context.scene.frame_set(i)

    square_obj.rotation_euler[0] = (i/animation_frames * rotation_angle) - rotation_angle  #+ (math.pi/2)

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



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

bpy.context.scene.frame_set(animation_frames)

square_obj.rotation_euler[0] = rotation_angle  #+ (math.pi/2)

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


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

#square_obj.rotation_euler = (1.5708, 0, 0)




# あああああああああああああああああああああああ




このブログの人気の投稿

基本の   線路レール

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

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