Updated lots of things

This commit is contained in:
2025-10-22 16:39:19 +03:00
parent 9c4bea5983
commit 3f0484e87c
56 changed files with 4497 additions and 160 deletions

BIN
assets/blender/edited-normal-female.blend (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
assets/blender/edited-normal-male.blend (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@@ -58,7 +58,7 @@ bpy.ops.ogre.export(filepath=scene_file,
EX_FORCE_LIGHTS=False,
EX_NODE_ANIMATION=True,
EX_MATERIALS=True,
EX_SEPARATE_MATERIALS=False,
EX_SEPARATE_MATERIALS=True,
EX_COPY_SHADER_PROGRAMS=True,
EX_MESH=True,
EX_LOD_LEVELS=3,

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python
import os, sys, time
import bpy
from math import pi
import glob
import shutil
from mathutils import Vector, Matrix
from math import radians, pi
argv = sys.argv
argv = argv[argv.index("--") + 1:]
sys.path.insert(0, os.getcwd() + "/assets/blender/scripts")
sys.path.insert(1, os.getcwd() + "/assets/blender/scripts/blender2ogre")
import io_ogre
output_file = argv[0]
print("Exporting to " + output_file)
basepath = os.getcwd()
# bpy.ops.export_scene.gltf(filepath="", check_existing=True,
# export_import_convert_lighting_mode='SPEC', gltf_export_id="",
# export_format='GLB', ui_tab='GENERAL', export_copyright="", export_image_format='AUTO',
# export_texture_dir="", export_jpeg_quality=75, export_keep_originals=False,
# export_texcoords=True, export_normals=True, export_draco_mesh_compression_enable=False,
# export_draco_mesh_compression_level=6, export_draco_position_quantization=14,
# export_draco_normal_quantization=10, export_draco_texcoord_quantization=12,
# export_draco_color_quantization=10, export_draco_generic_quantization=12, export_tangents=False,
# export_materials='EXPORT', export_original_specular=False, export_colors=True,
# export_attributes=False, use_mesh_edges=False, use_mesh_vertices=False, export_cameras=False,
# use_selection=False, use_visible=False, use_renderable=False,
# use_active_collection_with_nested=True, use_active_collection=False, use_active_scene=False,
# export_extras=False, export_yup=True, export_apply=False, export_animations=True,
# export_frame_range=False, export_frame_step=1, export_force_sampling=True, export_animation_mode='ACTIONS',
# export_nla_strips_merged_animation_name="Animation", export_def_bones=False,
# export_hierarchy_flatten_bones=False, export_optimize_animation_size=True,
# export_optimize_animation_keep_anim_armature=True, export_optimize_animation_keep_anim_object=False,
# export_negative_frame='SLIDE', export_anim_slide_to_zero=False, export_bake_animation=False,
# export_anim_single_armature=True, export_reset_pose_bones=True, export_current_frame=False,
# export_rest_position_armature=True, export_anim_scene_split_object=True, export_skins=True,
# export_all_influences=False, export_morph=True, export_morph_normal=True,
# export_morph_tangent=False, export_morph_animation=True, export_morph_reset_sk_data=True,
# export_lights=False, export_nla_strips=True, will_save_settings=False, filter_glob="*.glb")
for obj in bpy.data.objects:
if obj.name.endswith("-col"):
bpy.data.objects.remove(obj)
scene_file = output_file
#bpy.ops.ogre.export(filepath=scene_file,
# EX_SWAP_AXIS='xz-y',
# EX_V2_MESH_TOOL_VERSION='v2',
# EX_EXPORT_XML_DELETE=True,
# EX_SCENE=True,
# EX_SELECTED_ONLY=False,
# EX_EXPORT_HIDDEN=False,
# EX_FORCE_CAMERA=False,
# EX_FORCE_LIGHTS=False,
# EX_NODE_ANIMATION=True,
# EX_MATERIALS=True,
# EX_SEPARATE_MATERIALS=True,
# EX_COPY_SHADER_PROGRAMS=True,
# EX_MESH=True,
# EX_LOD_LEVELS=3,
# EX_LOD_DISTANCE=100,
# EX_LOD_PERCENT=40
#)
#
bpy.ops.ogre.export(filepath=scene_file,
EX_SWAP_AXIS='xz-y',
EX_V2_MESH_TOOL_VERSION='v2',
EX_EXPORT_XML_DELETE=True,
EX_SCENE=True,
EX_SELECTED_ONLY=False,
EX_EXPORT_HIDDEN=False,
EX_FORCE_CAMERA=False,
EX_FORCE_LIGHTS=False,
EX_NODE_ANIMATION=True,
EX_MATERIALS=True,
EX_SEPARATE_MATERIALS=True,
EX_COPY_SHADER_PROGRAMS=True,
EX_MESH=True
)
bpy.ops.wm.read_homefile(use_empty=True)
time.sleep(2)
bpy.ops.wm.quit_blender()

View File

@@ -9,7 +9,7 @@ from mathutils import Vector, Matrix
from math import radians, pi
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from settings import ExportMappingFemale, ExportMappingMale, ExportMappingMaleBabyShape, ExportMappingMaleEdited, ExportMappingFemaleEdited, ExportMappingMaleTestShapeEdited
from settings import ExportMappingFemale, ExportMappingMale, ExportMappingMaleBabyShape, ExportMappingMaleEdited, ExportMappingFemaleEdited, ExportMappingMaleTestShapeEdited, ExportMappingMaleBaseShapeEdited
basepath = os.getcwd()
def check_bone(bname):
@@ -179,7 +179,7 @@ def extra_linear(angle, offset):
ret += offt
return ret
for mapping in [ExportMappingFemale(), ExportMappingMale(), ExportMappingMaleBabyShape(), ExportMappingMaleEdited(), ExportMappingFemaleEdited(), ExportMappingMaleTestShapeEdited()]:
for mapping in [ExportMappingFemale(), ExportMappingMale(), ExportMappingMaleBabyShape(), ExportMappingMaleEdited(), ExportMappingFemaleEdited(), ExportMappingMaleTestShapeEdited(), ExportMappingMaleBaseShapeEdited()]:
if not os.path.exists(mapping.blend_path):
print("Skipping mapping: " + mapping.blend_path)
continue

View File

@@ -101,7 +101,7 @@ class ExportMappingMaleBabyShape:
gltf_path = "assets/blender/" + "characters/shapes/male/chibi/vroid-normal-male-chibi.gltf"
ogre_scene = "characters/shapes/male/chibi/vroid-normal-male-chibi.scene"
inner_path = "Object"
objs = ["male", "Body", "Hair", "Face"]
objs = ["male", "Body"]
armature_name = "male"
outfile = "tmp-male-chibi.blend"
default_action = 'default'
@@ -113,7 +113,21 @@ class ExportMappingMaleBabyShape:
class ExportMappingMaleTestShapeEdited:
blend_path = "assets/blender/" + "edited-shape-test-male.blend"
gltf_path = "characters/shapes/male/edited-shape-test-male.gltf"
ogre_scene = "characters/shapes/male/chibi/vroid-normal-male-chibi.scene"
ogre_scene = "characters/shapes/male/chibi/edited-shape-test-male.scene"
inner_path = "Object"
objs = ["male", "Body"]
armature_name = "male"
outfile = "tmp-male-chibi.blend"
default_action = 'default'
def __init__(self):
self.files = []
for fobj in self.objs:
self.files.append({"name": fobj})
class ExportMappingMaleBaseShapeEdited:
blend_path = "assets/blender/" + "edited-normal-male-base.blend"
gltf_path = "characters/shapes/male/edited-normal-male-base.gltf"
ogre_scene = "characters/shapes/male/chibi/edited-normal-male-base.scene"
inner_path = "Object"
objs = ["male", "Body"]
armature_name = "male"

View File

@@ -0,0 +1,127 @@
import bpy
import bmesh
import math
import os, sys, time
argv = sys.argv
argv = argv[argv.index("--") + 1:]
obj_name = argv[0]
basepath = os.getcwd()
print("Object: " + obj_name)
target_obj = None
for obj in bpy.data.objects:
if obj.name == obj_name:
target_obj = obj
break
target_obj.select_set(True)
bpy.context.view_layer.objects.active = target_obj
l = target_obj.data.uv_layers.new(name="UVMapCustom")
target_obj.data.uv_layers.active = l
bpy.ops.object.mode_set(mode='EDIT')
#bpy.ops.mesh.select_mode(type="FACE")
#bpy.ops.mesh.select_all(action='SELECT')
#bpy.ops.uv.unwrap(method='UNWRAP', fill_holes=True, correct_aspect=True, use_subsurf_data=False, margin=0.002)
## bpy.ops.uv.smart_project(angle_limit=66.0, island_margin=0.0, user_area_weight=0.0, use_aspect=True, stretch_to_bounds=True)
# bpy.ops.uv.unwrap()
bpy.ops.mesh.select_all(action='SELECT')
# bpy.ops.uv.unwrap()
bm = bmesh.new()
bm = bmesh.from_edit_mesh(obj.data)
uv_layer = bm.loops.layers.uv["UVMapCustom"]
for f in bm.faces:
f.select = True
bpy.ops.uv.unwrap(method='ANGLE_BASED', fill_holes=True, correct_aspect=True, margin=0.001)
#uv_layer = bm.loops.layers.uv.verify()
if False:
for f in bm.faces:
for l in f.loops:
vert = l.vert
if vert.co.x >= 0.0:
if vert.co.x < 0.225:
if vert.co.y >= 0.0:
l[uv_layer].uv.x = vert.co.x
if vert.co.z < 1.04:
#legs
px = vert.co.x - 0.1
pd = vert.co.y
a = (math.atan2(-pd, px) + math.pi) / (2.0 * math.pi)
l[uv_layer].uv.y = vert.co.z * 0.4
l[uv_layer].uv.x = a * 0.27
elif vert.co.z < 1.3477:
l[uv_layer].uv.y = vert.co.z * 0.5 - 0.1
elif vert.co.z < 1.5497:
#chest
l[uv_layer].uv.y = vert.co.z * 0.9 - 0.65
# elif vert.co.z < 1.5531:
# l[uv_layer].uv.y = vert.co.z * 0.99 - 0.8
else:
# head
pd = vert.co.y
px = vert.co.x
a = (math.atan2(-pd, px) + math.pi) / (2.0 * math.pi)
l[uv_layer].uv.y = vert.co.z * 0.8 - 0.47
l[uv_layer].uv.x = a * 0.8 - 0.2
else:
l[uv_layer].uv.x = 0.5 - vert.co.x
if vert.co.z < 1.04:
#legs
px = vert.co.x - 0.1
pd = vert.co.y
a = (math.atan2(-pd, px) + math.pi) / (2.0 * math.pi)
l[uv_layer].uv.y = vert.co.z * 0.4
l[uv_layer].uv.x = 0.195 + a * 0.3
elif vert.co.z < 1.3477:
l[uv_layer].uv.y = vert.co.z * 0.5 - 0.1
elif vert.co.z < 1.5497:
#chest
l[uv_layer].uv.y = vert.co.z * 0.9 - 0.65
else:
# head
pd = vert.co.y
px = vert.co.x
a = (math.atan2(-pd, px) + math.pi) / (2.0 * math.pi)
l[uv_layer].uv.y = vert.co.z * 0.8 - 0.47
l[uv_layer].uv.x = -0.2 + a * 0.8
else:
# arms
px = (vert.co.z - 1.395)
py = (-vert.co.x + 0.915)
pd = vert.co.y
a = (math.atan2(-pd, px - 0.049) + math.pi) / (2.0 * math.pi)
print(a)
l[uv_layer].uv.x = a * 0.14 + 0.18
l[uv_layer].uv.y = (-vert.co.x + 0.915) * 0.7 + 0.05
else:
if vert.co.x < 0.225:
#not arms
l[uv_layer].uv.x = vert.co.x - 5.0
l[uv_layer].uv.y = vert.co.z
else:
#arms
l[uv_layer].uv.x = vert.co.x - 5.0
l[uv_layer].uv.y = vert.co.z
for f in bm.faces:
for l in f.loops:
vert = l.vert
if vert.co.z < 1.04:
#legs
px = vert.co.x - 0.1
pd = vert.co.y
a = (math.atan2(-pd, px) + math.pi) / (2.0 * math.pi)
l[uv_layer].uv.y = vert.co.z * 0.4
if vert.co.x >= 0.0:
l[uv_layer].uv.x = a * 0.27
else:
l[uv_layer].uv.x = a * 0.27 - 1.0
bmesh.update_edit_mesh(obj.data)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.wm.save_as_mainfile(filepath="tmp.blend")

BIN
assets/blender/vehicles/boat.blend (Stored with Git LFS)

Binary file not shown.