Animation fixes + fonts

This commit is contained in:
2025-09-15 23:55:31 +03:00
parent 1bc0f298fc
commit 1aa002d8ba
10 changed files with 111 additions and 3 deletions

1
.gitattributes vendored
View File

@@ -4,3 +4,4 @@
*.vroid filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text

View File

@@ -275,7 +275,7 @@ file(GLOB VRM_FILES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/assets/vroi
file(GLOB MIXAMO_FILES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/assets/blender/mixamo/**/*.fbx)
file(GLOB EDITED_BLENDS RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/assets/blender/edited-*.blend)
set(VRM_SOURCE)
foreach(VRM_FILE ${VRM_FILES} ${MIXAMO_FILES} ${EDITED_BLENDS})
foreach(VRM_FILE ${VRM_FILES} ${MIXAMO_FILES})
set(OUTPUT_FILE "${CMAKE_BINARY_DIR}/${VRM_FILE}")
set(INPUT_FILE "${CMAKE_SOURCE_DIR}/${VRM_FILE}")
add_custom_command(OUTPUT "${OUTPUT_FILE}"
@@ -298,6 +298,30 @@ add_custom_command(OUTPUT ${VRM_IMPORTED_BLENDS}
${VRM_SOURCE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set(EDITED_BLENDS_LIST
male
female
)
set(EDITED_BLEND_TARGETS)
foreach(EDITED_BLEND ${EDITED_BLENDS_LIST})
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend
DEPENDS ${CMAKE_SOURCE_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend
${CMAKE_BINARY_DIR}/assets/blender/vrm-vroid-normal-${EDITED_BLEND}.blend
COMMAND ${CMAKE_COMMAND}
-E copy ${CMAKE_SOURCE_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend
${CMAKE_BINARY_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend
COMMAND ${BLENDER} -b -Y
${CMAKE_BINARY_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend
-P ${CMAKE_SOURCE_DIR}/assets/blender/scripts/copy_animations.py --
${CMAKE_BINARY_DIR}/assets/blender/vrm-vroid-normal-male.blend
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
list(APPEND EDITED_BLEND_TARGETS ${CMAKE_BINARY_DIR}/assets/blender/edited-normal-${EDITED_BLEND}.blend)
endforeach()
add_custom_target(edited-blends DEPENDS ${EDITED_BLEND_TARGETS})
set(CHARACTER_GLBS
${CMAKE_BINARY_DIR}/characters/male/normal-male.glb
${CMAKE_BINARY_DIR}/characters/female/normal-female.glb
@@ -307,7 +331,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory ${CREATE_DIRECTORIES}
COMMAND ${BLENDER} -b -Y -P ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_models.py
COMMAND ${CMAKE_COMMAND} -E touch ${CHARACTER_GLBS}
DEPENDS ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_models.py ${VRM_IMPORTED_BLENDS} ${EDITED_BLENDS}
DEPENDS ${CMAKE_SOURCE_DIR}/assets/blender/scripts/export_models.py ${VRM_IMPORTED_BLENDS}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#add_custom_command(
# OUTPUT ${CMAKE_SOURCE_DIR}/characters/female/vroid-normal-female.scene
@@ -330,7 +354,8 @@ add_custom_command(
add_custom_target(stage_files ALL DEPENDS ${CMAKE_BINARY_DIR}/resources.cfg ${MATERIALS_OUTPUT}
${CMAKE_BINARY_DIR}/resources/terrain/world_map.png
${CMAKE_BINARY_DIR}/resources/terrain/brushes.png)
${CMAKE_BINARY_DIR}/resources/terrain/brushes.png
edited-blends)
add_custom_target(remove_scenes COMMAND rm -f ${VRM_SOURCE} ${VRM_IMPORTED_BLENDS} ${CHARACTER_GLBS})

View File

@@ -0,0 +1,64 @@
import bpy
import sys
import os
argv = sys.argv
argv = argv[argv.index("--") + 1:]
sys.path.insert(0, os.getcwd() + "/assets/blender/scripts")
source_filepath = argv[0]
armature_name = argv[1]
print("starting...")
def copy_actions_and_create_nla_tracks(source_filepath, target_object_name):
"""
Copies actions from a source Blender file that do not exist in the current
file, creates NLA tracks for them on a target object, and saves the file.
Args:
source_filepath (str): The full path to the source Blender file.
target_object_name (str): The name of the object in the current file
to which the actions and NLA tracks will be applied.
"""
# 1. Link or Append Actions from the Source File
with bpy.data.libraries.load(source_filepath, link=False) as (data_from, data_to):
source_action_names = data_from.actions
current_action_names = {action.name for action in bpy.data.actions}
actions_to_append = [name for name in source_action_names if name not in current_action_names]
data_to.actions = actions_to_append
print(actions_to_append)
# Get the target object
target_object = bpy.data.objects.get(target_object_name)
if not target_object:
print(f"Error: Object '{target_object_name}' not found in the current file.")
return
# Ensure the object has an NLA editor
if not target_object.animation_data:
target_object.animation_data_create()
# 2. Iterate through newly imported actions and create NLA tracks
for action in data_to.actions:
# Check if an action with the same name already exists in the current file
# Add the action to the NLA editor as a strip
nla_track = target_object.animation_data.nla_tracks.new()
nla_track.name = f"NLA_Track_{action.name}"
nla_track.strips.new(name=action.name, start=1, action=action)
print(f"Created NLA track for action: {action.name}")
# 3. Save the current Blender file
bpy.ops.wm.save_as_mainfile(filepath=bpy.context.blend_data.filepath)
print(f"File saved: {bpy.context.blend_data.filepath}")
# --- Usage Example ---
if __name__ == "__main__":
# Replace with your actual source file path and target object name
source_file = source_filepath
target_obj = armature_name
copy_actions_and_create_nla_tracks(source_file, target_obj)

BIN
assets/fonts/Jupiteroid-Bold.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/fonts/Jupiteroid-BoldItalic.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/fonts/Jupiteroid-Italic.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/fonts/Jupiteroid-Light.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/fonts/Jupiteroid-LightItalic.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/fonts/Jupiteroid-Regular.ttf (Stored with Git LFS) Normal file

Binary file not shown.