Set new type of animation

This commit is contained in:
Vladislav Khorev 2026-04-22 20:45:40 +03:00
parent 52c4ad8ee0
commit 4d9a5b0a6e
49 changed files with 684419 additions and 64 deletions

View File

@ -0,0 +1,370 @@
#!/usr/bin/env python3
"""
Convert a text-based multi-mesh bone animation file to the BSMF binary format.
Usage:
python convert_anim_to_binary_new.py <input.txt> <output.bin>
Binary format (BSMF v2) -- all values little-endian:
HEADER
4 bytes magic "BSMF"
uint32 version (2)
ARMATURE MATRIX
16 x float 4x4 matrix (row-major)
BONES
uint32 numBones
per bone:
3 x float boneStartWorld (from HEAD_LOCAL)
float boneLength
9 x float 3x3 rotation matrix (row-major)
int32 parentIndex (-1 if none)
uint32 numChildren
numChildren x int32 childIndices
BONE NAMES
per bone:
uint32 nameLen
nameLen bytes UTF-8 name (no terminator)
MESHES
uint32 numMeshes
per mesh:
uint32 nameLength
nameLength x char meshName (UTF-8, no null terminator)
VERTICES
uint32 numVertices
numVertices x 3 x float positions
UV COORDINATES
uint32 numFaces
numFaces x 6 x float 3 UV pairs per face (u0,v0,u1,v1,u2,v2)
NORMALS
numVertices x 3 x float normals
TRIANGLES
uint32 numTriangles
numTriangles x 3 x int32 vertex indices
VERTEX WEIGHTS
per vertex (numVertices):
uint32 numGroups
numGroups x (int32 boneIndex, float weight)
ANIMATION KEYFRAMES
uint32 numKeyframes
per keyframe:
int32 frameNumber
per bone (numBones, in index order 0..N-1):
3 x float location
16 x float 4x4 matrix (row-major)
"""
import struct
import re
import sys
def parse_floats(line):
return [float(x) for x in re.findall(r'[-]?\d+\.\d+', line)]
def parse_first_int(line):
m = re.search(r'\d+', line)
if m:
return int(m.group())
raise ValueError(f"No integer found in: {line}")
def parse_children(line):
return re.findall(r"'([^']+)'", line)
def convert(input_path, output_path):
with open(input_path, 'r', encoding='utf-8', errors='replace') as f:
lines = f.readlines()
idx = 0
def next_line():
nonlocal idx
line = lines[idx].rstrip()
idx += 1
return line
# --- Armature matrix header + 4 rows ---
next_line() # "=== Armature Matrix ==="
armature_matrix = []
for _ in range(4):
armature_matrix.extend(parse_floats(next_line())[:4])
# --- Bone count ---
line = next_line() # "=== Armature Bones: 65"
num_bones = parse_first_int(line)
bone_names = []
bones = []
bone_parent_names = []
bone_children_names = []
for _ in range(num_bones):
bone = {}
# "Bone: mixamorig:Hips"
line = next_line()
bone_name = line[6:]
bone_names.append(bone_name)
# " HEAD_LOCAL: <Vector (x, y, z)>"
line = next_line()
bone['head'] = parse_floats(line)[:3]
# " TAIL_LOCAL: ..." -- skip
next_line()
# " Length: 0.123"
line = next_line()
bone['length'] = parse_floats(line)[0]
# 3x3 matrix (3 rows)
mat = []
for _ in range(3):
mat.extend(parse_floats(next_line()))
bone['matrix_3x3'] = mat
# " Parent: None" or " Parent: boneName"
line = next_line()
if line == " Parent: None":
bone_parent_names.append(None)
else:
bone_parent_names.append(line[10:])
# " Children: ['a', 'b'] or []"
line = next_line()
bone_children_names.append(parse_children(line))
bones.append(bone)
# Build name -> index map
name_to_idx = {name: i for i, name in enumerate(bone_names)}
# Resolve parent / child indices
for i in range(num_bones):
if bone_parent_names[i] is None:
bones[i]['parent'] = -1
else:
bones[i]['parent'] = name_to_idx[bone_parent_names[i]]
bones[i]['children'] = [name_to_idx[c] for c in bone_children_names[i]]
# --- Multi-mesh header ---
line = next_line() # "=== TOTAL MESHES TO EXPORT: 7 ==="
num_meshes = parse_first_int(line)
meshes = []
for _ in range(num_meshes):
# "=== Mesh Object: Name ==="
line = next_line()
m = re.match(r"===\s*Mesh Object:\s*(.+?)\s*===$", line)
if not m:
raise ValueError(f"Invalid mesh header: {line}")
mesh_name = m.group(1)
# --- Vertices ---
line = next_line() # "===Vertices: N"
num_vertices = parse_first_int(line)
vertices = []
for _ in range(num_vertices):
vertices.append(parse_floats(next_line())[:3])
# --- UV Coordinates ---
next_line() # "===UV Coordinates:"
line = next_line() # "Face count: M"
num_faces = parse_first_int(line)
uvs = []
for _ in range(num_faces):
next_line() # "Face N"
next_line() # "UV Count: 3"
face_uvs = []
for _ in range(3):
face_uvs.extend(parse_floats(next_line())[:2])
uvs.append(face_uvs)
# --- Normals ---
next_line() # "===Normals:"
normals = []
for _ in range(num_vertices):
normals.append(parse_floats(next_line())[:3])
# --- Triangles ---
line = next_line() # "===Triangles: M"
num_triangles = parse_first_int(line)
triangles = []
for _ in range(num_triangles):
line = next_line()
ints = [int(x) for x in re.findall(r'[-]?\d+', line)]
triangles.append(ints[:3])
# --- Vertex Weights ---
next_line() # "=== Vertex Weights (Max 5 bones per vertex) ==="
vertex_weights = []
for _ in range(num_vertices):
next_line() # "Vertex N:"
line = next_line() # "Vertex groups: K"
num_groups = parse_first_int(line)
groups = []
for _ in range(num_groups):
line = next_line()
m = re.search(r"'([^']+)'.*?([-]?\d+\.\d+)", line)
bone_name = m.group(1)
weight = float(m.group(2))
groups.append((name_to_idx[bone_name], weight))
vertex_weights.append(groups)
meshes.append({
'name': mesh_name,
'num_vertices': num_vertices,
'vertices': vertices,
'num_faces': num_faces,
'uvs': uvs,
'normals': normals,
'num_triangles': num_triangles,
'triangles': triangles,
'vertex_weights': vertex_weights,
})
# --- Animation Keyframes ---
next_line() # "=== Animation Keyframes ==="
next_line() # "=== Bone Transforms per Keyframe ==="
line = next_line() # "Keyframes: N"
num_keyframes = parse_first_int(line)
keyframes = []
for _ in range(num_keyframes):
line = next_line() # "Frame: N"
frame_number = parse_first_int(line)
bone_data = {}
for _ in range(num_bones):
line = next_line() # " Bone: mixamorig:Hips"
bone_name = line.strip()
if bone_name.startswith("Bone: "):
bone_name = bone_name[6:]
bone_idx = name_to_idx[bone_name]
# Location
location = parse_floats(next_line())[:3]
# Rotation (skip)
next_line()
# " Matrix:" (skip header)
next_line()
# 4 rows of 4 floats
matrix = []
for _ in range(4):
matrix.extend(parse_floats(next_line()))
bone_data[bone_idx] = {
'location': location,
'matrix': matrix,
}
keyframes.append((frame_number, bone_data))
# ================================================================
# Write binary file
# ================================================================
with open(output_path, 'wb') as out:
# Header
out.write(b'BSMF')
out.write(struct.pack('<I', 2))
# Armature matrix (16 floats, row-major)
out.write(struct.pack('<16f', *armature_matrix))
# Bones
out.write(struct.pack('<I', num_bones))
for i in range(num_bones):
b = bones[i]
out.write(struct.pack('<3f', *b['head']))
out.write(struct.pack('<f', b['length']))
out.write(struct.pack('<9f', *b['matrix_3x3']))
out.write(struct.pack('<i', b['parent']))
out.write(struct.pack('<I', len(b['children'])))
for c in b['children']:
out.write(struct.pack('<i', c))
# Bone names
for name in bone_names:
name_bytes = name.encode('utf-8')
out.write(struct.pack('<I', len(name_bytes)))
out.write(name_bytes)
# Meshes
out.write(struct.pack('<I', num_meshes))
for md in meshes:
name_bytes = md['name'].encode('utf-8')
out.write(struct.pack('<I', len(name_bytes)))
out.write(name_bytes)
# Vertices
out.write(struct.pack('<I', md['num_vertices']))
for v in md['vertices']:
out.write(struct.pack('<3f', *v))
# UV Coordinates
out.write(struct.pack('<I', md['num_faces']))
for uv in md['uvs']:
out.write(struct.pack('<6f', *uv))
# Normals
for n in md['normals']:
out.write(struct.pack('<3f', *n))
# Triangles
out.write(struct.pack('<I', md['num_triangles']))
for t in md['triangles']:
out.write(struct.pack('<3i', *t))
# Vertex weights
for vw in md['vertex_weights']:
out.write(struct.pack('<I', len(vw)))
for bone_idx, weight in vw:
out.write(struct.pack('<if', bone_idx, weight))
# Animation Keyframes
out.write(struct.pack('<I', num_keyframes))
for frame_num, bone_data in keyframes:
out.write(struct.pack('<i', frame_num))
for i in range(num_bones):
bd = bone_data[i]
out.write(struct.pack('<3f', *bd['location']))
out.write(struct.pack('<16f', *bd['matrix']))
input_size = sum(len(l) for l in lines)
import os
output_size = os.path.getsize(output_path)
print(f"Converted: {input_path} ({input_size:,} bytes text) -> {output_path} ({output_size:,} bytes binary)")
print(f" Bones: {num_bones}, Meshes: {num_meshes}, Keyframes: {num_keyframes}")
for md in meshes:
print(f" - {md['name']}: {md['num_vertices']} verts, "
f"{md['num_faces']} faces, {md['num_triangles']} tris")
if __name__ == '__main__':
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <input.txt> <output.bin>")
sys.exit(1)
convert(sys.argv[1], sys.argv[2])

View File

@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""
Convert an old single-mesh text animation file to the new multi-mesh text format.
The only structural difference is that the new format wraps the mesh block
between these two extra headers before the "===Vertices:" line:
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
Usage:
python convert_old_anim_to_new.py <input.txt> <output.txt> [mesh_name]
If mesh_name is omitted, "Body" is used.
"""
import sys
def convert(input_path, output_path, mesh_name="Body"):
with open(input_path, 'r', encoding='utf-8', errors='replace') as f:
lines = f.readlines()
# Find the first "===Vertices:" line -- that's where the bone block ends
# and the mesh block begins in the old format.
insert_at = None
for i, line in enumerate(lines):
if line.lstrip().startswith("===Vertices:"):
insert_at = i
break
if insert_at is None:
raise RuntimeError("Could not find '===Vertices:' line in input file")
header_lines = [
"=== TOTAL MESHES TO EXPORT: 1 ===\n",
f"=== Mesh Object: {mesh_name} ===\n",
]
out_lines = lines[:insert_at] + header_lines + lines[insert_at:]
with open(output_path, 'w', encoding='utf-8') as out:
out.writelines(out_lines)
print(f"Converted: {input_path} -> {output_path} (mesh name: {mesh_name})")
if __name__ == '__main__':
if len(sys.argv) not in (3, 4):
print(f"Usage: {sys.argv[0]} <input.txt> <output.txt> [mesh_name]")
sys.exit(1)
mesh_name = sys.argv[3] if len(sys.argv) == 4 else "Body"
convert(sys.argv[1], sys.argv[2], mesh_name)

View File

@ -77,6 +77,8 @@ set(SOURCES
../src/AudioPlayerAsync.h
../src/BoneAnimatedModel.cpp
../src/BoneAnimatedModel.h
../src/BoneAnimatedModelNew.cpp
../src/BoneAnimatedModelNew.h
../src/render/OpenGlExtensions.cpp
../src/render/OpenGlExtensions.h
../src/utils/Utils.cpp

View File

@ -30,6 +30,8 @@ add_executable(space-game001
../src/AudioPlayerAsync.h
../src/BoneAnimatedModel.cpp
../src/BoneAnimatedModel.h
../src/BoneAnimatedModelNew.cpp
../src/BoneAnimatedModelNew.h
../src/render/OpenGlExtensions.cpp
../src/render/OpenGlExtensions.h
../src/utils/Utils.cpp

BIN
resources/w/default_float001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (-10.7783, 24.5645, -17.1880)>
Vertex 1: <Vector (-10.6158, 24.6950, -17.2721)>

BIN
resources/w/default_float001_cut.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (-10.7783, 24.5645, -17.1880)>
Vertex 1: <Vector (-10.6158, 24.6950, -17.2721)>

BIN
resources/w/default_idle002.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (15.1097, 136.8879, -4.2822)>
Vertex 1: <Vector (14.3822, 136.6658, -3.0860)>

BIN
resources/w/default_walk001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Bodyt ===
===Vertices: 24256
Vertex 0: <Vector (15.5683, 124.7914, -6.6797)>
Vertex 1: <Vector (16.0870, 125.1060, -5.3985)>

BIN
resources/w/float_attack003.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (13.7486, 127.5152, -3.7139)>
Vertex 1: <Vector (13.3248, 127.5237, -2.3612)>

BIN
resources/w/float_attack003_cut.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (13.7486, 127.5152, -3.7139)>
Vertex 1: <Vector (13.3248, 127.5237, -2.3612)>

BIN
resources/w/gg/gg_action_attack001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (-0.0064, 1.3563, -0.1469)>
Vertex 1: <Vector (0.0033, 1.3608, -0.0847)>

BIN
resources/w/gg/gg_action_idle001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (-0.0096, 1.3378, -0.1407)>
Vertex 1: <Vector (0.0020, 1.3429, -0.0792)>

BIN
resources/w/gg/gg_action_to_stand001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (-0.0096, 1.3378, -0.1407)>
Vertex 1: <Vector (0.0020, 1.3429, -0.0792)>

BIN
resources/w/gg/gg_stand_idle001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (0.0384, 1.6114, -0.1034)>
Vertex 1: <Vector (0.0393, 1.6148, -0.1060)>

BIN
resources/w/gg/gg_stand_to_action002.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (0.0385, 1.6114, -0.1035)>
Vertex 1: <Vector (0.0393, 1.6148, -0.1061)>

BIN
resources/w/gg/gg_walking001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (0.0000, -0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5140
Vertex 0: <Vector (0.0410, 1.6083, -0.0980)>
Vertex 1: <Vector (0.0365, 1.6057, -0.0999)>

Binary file not shown.

View File

@ -571,6 +571,8 @@ Bone: RightToeBase
<Vector (-0.1875, 0.5863, 0.7881)>
Parent: RightFoot
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5182
Vertex 0: <Vector (-0.0447, -0.1686, 0.6762)>
Vertex 1: <Vector (-0.0263, -0.1209, 0.6553)>

BIN
resources/w/gg/new/gg_stand_idle001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -571,6 +571,8 @@ Bone: RightToeBase
<Vector (-0.1875, 0.5863, 0.7881)>
Parent: RightFoot
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5182
Vertex 0: <Vector (0.0134, -0.0534, 0.7837)>
Vertex 1: <Vector (0.0108, 0.0010, 0.7873)>

Binary file not shown.

View File

@ -571,6 +571,8 @@ Bone: RightToeBase
<Vector (-0.1875, 0.5863, 0.7881)>
Parent: RightFoot
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5182
Vertex 0: <Vector (0.0134, -0.0425, 0.7784)>
Vertex 1: <Vector (0.0108, 0.0112, 0.7868)>

BIN
resources/w/gg/new/gg_walk001.anim (Stored with Git LFS)

Binary file not shown.

View File

@ -571,6 +571,8 @@ Bone: RightToeBase
<Vector (-0.1875, 0.5863, 0.7881)>
Parent: RightFoot
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 5182
Vertex 0: <Vector (-0.0021, -0.0623, 0.7245)>
Vertex 1: <Vector (0.0086, -0.0136, 0.7178)>

BIN
resources/w/new_anims/gg_run003.anim (Stored with Git LFS) Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
resources/w/new_anims/gg_stand_idle003.anim (Stored with Git LFS) Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
resources/w/zombie002.anim (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -472,6 +472,8 @@ Bone: R_Thumb3
<Vector (0.0000, 0.0000, 1.0000)>
Parent: R_Thumb2
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 24256
Vertex 0: <Vector (13.1386, 114.0676, 6.8428)>
Vertex 1: <Vector (13.0500, 114.3342, 8.2323)>

BIN
resources/w/zombie_idle001.anim (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -589,6 +589,8 @@ Bone: mixamorig:RightToe_End
<Vector (-0.0000, 0.0000, 1.0000)>
Parent: mixamorig:RightToeBase
Children: []
=== TOTAL MESHES TO EXPORT: 1 ===
=== Mesh Object: Body ===
===Vertices: 6463
Vertex 0: <Vector (-0.0160, 1.3186, 0.2497)>
Vertex 1: <Vector (0.0109, 1.5042, 0.2547)>

View File

@ -167,6 +167,7 @@ namespace ZL
startBones = bones;
currentBones = bones;
this->boneNames = boneNames;
// ---- Multi-mesh header ----
std::getline(f, tempLine); // === TOTAL MESHES TO EXPORT: N ===
@ -487,7 +488,7 @@ namespace ZL
if (std::memcmp(magic, "BSMF", 4) != 0)
throw std::runtime_error("Invalid multi-mesh binary animation file (bad magic)");
uint32_t version = readUint32();
if (version != 1)
if (version != 2)
throw std::runtime_error("Unsupported multi-mesh binary animation file version");
// Armature matrix (row-major in file, stored with stride-4 into Matrix4f)
@ -528,6 +529,11 @@ namespace ZL
startBones = bones;
currentBones = bones;
// Bone names
boneNames.resize(numBones);
for (uint32_t i = 0; i < numBones; i++)
boneNames[i] = readString();
// Meshes
uint32_t numMeshes = readUint32();
@ -629,6 +635,15 @@ namespace ZL
}
}
int BoneSystemNew::findBoneIndex(const std::string& name) const
{
for (size_t i = 0; i < boneNames.size(); i++)
{
if (boneNames[i] == name) return static_cast<int>(i);
}
return -1;
}
void BoneSystemNew::Interpolate(int frame)
{
int startingKeyFrame = -1;

View File

@ -20,6 +20,7 @@ namespace ZL
std::vector<Bone> startBones;
std::vector<Bone> currentBones;
std::vector<std::string> boneNames;
std::vector<Animation> animations;
int startingFrame = 0;
@ -28,6 +29,8 @@ namespace ZL
void LoadFromBinaryFile(const std::string& fileName, const std::string& ZIPFileName = "");
void Interpolate(int frame);
int findBoneIndex(const std::string& name) const;
};
struct MeshGpuSkinningData

View File

@ -315,10 +315,14 @@ void Character::draw(Renderer& renderer) {
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
auto& anim = it->second;
modelMutable.AssignFrom(anim.model.mesh);
modelMutable.RefreshVBO();
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
renderer.DrawVertexRenderStruct(modelMutable);
for (const auto& name : anim.model.meshNamesOrdered) {
auto mit = anim.model.meshes.find(name);
if (mit == anim.model.meshes.end()) continue;
modelMutable.AssignFrom(mit->second.mesh);
modelMutable.RefreshVBO();
renderer.DrawVertexRenderStruct(modelMutable);
}
renderer.PopMatrix();
@ -370,17 +374,7 @@ void Character::drawGpuSkinning(Renderer& renderer) {
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
// Bind VAO (desktop only)
#ifndef EMSCRIPTEN
#ifndef __ANDROID__
if (anim.gpuSkinningShaderData.bindPoseMutable.vao) {
glBindVertexArray(anim.gpuSkinningShaderData.bindPoseMutable.vao->getBuffer());
renderer.shaderManager.EnableVertexAttribArrays();
}
#endif
#endif
anim.gpuSkinningShaderData.RenderVBO(renderer);
anim.gpuSkinningShaderData.RenderVBO(renderer, anim.model.meshNamesOrdered);
renderer.PopMatrix();
@ -477,9 +471,13 @@ void Character::drawShadowDepthCpu(Renderer& renderer) {
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
auto& anim = it->second;
modelMutable.AssignFrom(anim.model.mesh);
modelMutable.RefreshVBO();
renderer.DrawVertexRenderStruct(modelMutable);
for (const auto& name : anim.model.meshNamesOrdered) {
auto mit = anim.model.meshes.find(name);
if (mit == anim.model.meshes.end()) continue;
modelMutable.AssignFrom(mit->second.mesh);
modelMutable.RefreshVBO();
renderer.DrawVertexRenderStruct(modelMutable);
}
renderer.PopMatrix();
drawAttachedWeapon(renderer);
@ -516,7 +514,7 @@ void Character::drawShadowDepthGpuSkinning(Renderer& renderer) {
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
CheckGlError(__FILE__, __LINE__);
it->second.gpuSkinningShaderData.RenderVBO(renderer);
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
CheckGlError(__FILE__, __LINE__);
renderer.PopMatrix();
@ -565,10 +563,14 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
auto& anim = it->second;
modelMutable.AssignFrom(anim.model.mesh);
modelMutable.RefreshVBO();
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
renderer.DrawVertexRenderStruct(modelMutable);
for (const auto& name : anim.model.meshNamesOrdered) {
auto mit = anim.model.meshes.find(name);
if (mit == anim.model.meshes.end()) continue;
modelMutable.AssignFrom(mit->second.mesh);
modelMutable.RefreshVBO();
renderer.DrawVertexRenderStruct(modelMutable);
}
renderer.PopMatrix();
@ -628,7 +630,7 @@ void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matri
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
CheckGlError(__FILE__, __LINE__);
it->second.gpuSkinningShaderData.RenderVBO(renderer);
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
renderer.PopMatrix();

View File

@ -1,5 +1,5 @@
#pragma once
#include "BoneAnimatedModel.h"
#include "BoneAnimatedModelNew.h"
#include "render/Renderer.h"
#include "render/TextureManager.h"
#include "items/Item.h"
@ -85,7 +85,7 @@ public:
private:
std::map<AnimationState, BoneAnimationData> animations;
std::map<AnimationState, BoneAnimationDataNew> animations;
VertexRenderStruct modelMutable;
std::shared_ptr<Texture> texture;

View File

@ -520,15 +520,9 @@ namespace ZL
}
for (auto& npc : npcs)
{
if (npc->canAttack)
{
npc->update(delta);
}
//npc->update(delta);
npc->update(delta);
}
// Check if player reached target interactive object
if (targetInteractiveObject && player) {
float distToObject = (player->position - targetInteractiveObject->position).norm();