I'm applying the same animation matrix to the normals (with 0.0 as w component of the vec4 as this is a vector not a point).
Upon closer inspection the main problem seems to be in the fold of the book. Here both joints of the opening halfs are applied. Maybe that causes problems as the cancel each other out.
I've spent the last couple of evenings implementing a #GLTF 2.0 parser to support animations. Today I've achieved the first step towards that goal and can now load meshes from .glb files.
I've implemented a new algorithm to create level layouts. The previous approach added on chamber after the other only connecting it at one suitable location. This lead to "tree like" layout.
The new approach creates a Delaunay triangulation where each chambers center is a vertex. Then it discards edges as long as the graph stays connected. The remaining edge are used to as corridors.
Worked a bit on my project which currently acts as a dungeon/level generator. Added the ability to use multiple textures for different parts of the room.
I made a small improvement to the corridor curve sampling to create an equidistant sampling.
let t_samples = 100;
// determine length of path
let path_len = {
let mut l = 0.0;
let mut prev_point = control_a;
for t in 1..=t_samples {
let t = t as f32 / t_samples as f32;
let point = corridor.sample(t);
l += point.pos.dist(&prev_point);
prev_point = point.pos;
}
l
};
// determine spacing based on a desired spacing
// E.g. if we want 1.0 spacing but the curve is 1.1 long,
// a naive approach would result in a 0.1 segment at the end.
// Instead we want a 1.1 segement or a 0.55 segment
let desired_spacing = 1.0;
let spacing = {
let needed_steps = path_len / desired_spacing;
let low = needed_steps.floor().max(1.0);
let high = needed_steps.ceil();
let low_step = path_len / low;
let high_step = path_len / high;
if (low_step - desired_spacing).abs() <= (high_step - desired_spacing).abs() {
low_step
} else {
high_step
}
};
let mut dist = 0.0;
let mut prev_dist_point = control_a;
for t in 1..t_samples {
let t = t as f32 / t_samples as f32;
let point = corridor.sample(t);
dist += point.pos.dist(&prev_dist_point);
prev_dist_point = point.pos;
if dist >= spacing {
// create sample point
}
}