WindowsでImageMagick
https://imagemagick.org/index.php
でフォルダとサブフォルダ内のpng画像ファイルのサイズを1024x1024に変える方法
コマンドプロンプトでフォルダに移動し
forfiles /S /M *.png /C "cmd /c magick mogrify -resize 1024x1024 @path
を実行
The main content is the process of creating the game engine assets currently being created.
WindowsでImageMagick
https://imagemagick.org/index.php
でフォルダとサブフォルダ内のpng画像ファイルのサイズを1024x1024に変える方法
コマンドプロンプトでフォルダに移動し
forfiles /S /M *.png /C "cmd /c magick mogrify -resize 1024x1024 @path
を実行
import bpy
# 選択されたメッシュオブジェクトを取得
selected_meshes = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH']
for mesh in selected_meshes:
# すべてのオブジェクトの選択を解除
bpy.ops.object.select_all(action='DESELECT')
# メッシュを選択
mesh.select_set(True)
# メッシュに関連付けられているアーマチュアを探す
armature = None
if mesh.parent and mesh.parent.type == 'ARMATURE':
armature = mesh.parent
armature.select_set(True)
# アクティブなオブジェクトを設定 (エクスポートの際に必要)
bpy.context.view_layer.objects.active = mesh
# FBXとしてエクスポート
bpy.ops.export_scene.fbx(
filepath=f"path_to_save/{mesh.name}.fbx",
use_selection=True,
mesh_smooth_type='FACE',
bake_anim=False,
add_leaf_bones=False,
primary_bone_axis='X',
secondary_bone_axis='Y',
global_scale=1.0
)
import bpy
import json
# テキストファイルからエクスポートリストを読み込む
with open("your_filepath/export_list.txt", "r") as file:
export_list = json.load(file)
# 各オブジェクトグループをFBXとしてエクスポート
for group in export_list:
# すべてのオブジェクトの選択を解除
bpy.ops.object.select_all(action='DESELECT')
# グループ内のオブジェクトを選択
for obj_name in group:
obj = bpy.data.objects.get(obj_name)
if obj:
obj.select_set(True)
# アクティブなオブジェクトを設定 (エクスポートの際に必要)
bpy.context.view_layer.objects.active = bpy.data.objects.get(group[0])
# FBXとしてエクスポート
bpy.ops.export_scene.fbx(
filepath=f"your_filepath/{group[0]}.fbx",
#filepath=f"path_to_save/{'_'.join(group)}.fbx",
use_selection=True,
# 出力設定色々
mesh_smooth_type='FACE',
bake_anim=False,
add_leaf_bones=False,
primary_bone_axis='X',
secondary_bone_axis='Y',
global_scale=0.01
)
----------------------------------------------------------------
[
["Mesh1", "Armature1"],
["Mesh2", "Mesh3"],
["Armature1"]
]
import unreal
# エディタ内で選択されたアセットを取得
selected_assets = unreal.EditorUtilityLibrary.get_selected_assets()
for asset in selected_assets:
if isinstance(asset, unreal.Texture2D):
# Texture GroupをCharacterに設定
asset.set_editor_property('LODGroup', unreal.TextureGroup.TEXTUREGROUP_CHARACTER)
# アセットの変更を保存
unreal.EditorAssetLibrary.save_loaded_asset(asset)
#他の値に変更する場合はTEXTUREGROUP_CHARACTERの代わりに以下のEnumを使用する
#https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/TextureGroup.html
import bpy
import math
def find_nearest_bone(target_bone, reference_armature):
min_distance = float('inf')
nearest_bone_name = None
for bone in reference_armature.data.bones:
distance = (bone.head - target_bone.head).length
if distance < min_distance:
min_distance = distance
nearest_bone_name = bone.name
return nearest_bone_name
# ArmatureAとArmatureBを取得
armature_a = bpy.data.objects.get("ArmatureA")
armature_b = bpy.data.objects.get("ArmatureB")
# ArmatureAがアーマチュアであることを確認
if armature_a and armature_a.type == 'ARMATURE':
# ArmatureBがアーマチュアであることを確認
if armature_b and armature_b.type == 'ARMATURE':
# ArmatureAのボーンに対して処理を行う
for bone_a in armature_a.data.bones:
# ArmatureBの中で一番近いボーンを見つける
nearest_bone_name = find_nearest_bone(bone_a, armature_b)
# ボーンの名前を変更
bone_a.name = nearest_bone_name
else:
print("ArmatureB is not an armature.")
else:
print("ArmatureA is not an armature.")