From e7ac3ee43c477664e340ba6b3682587abd8be991 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Tue, 4 Jul 2023 12:56:20 -0700 Subject: [PATCH] Walking animation working on desktop and web - Skeleton texture is clamp to edge because it's an NPOT on webgl 1 --- art/Exporter.py | 2 +- art/art.blend | 4 ++-- main.c | 36 +++++++++++------------------------- tuning.h | 2 +- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/art/Exporter.py b/art/Exporter.py index fe72e37..7ec8be2 100644 --- a/art/Exporter.py +++ b/art/Exporter.py @@ -135,7 +135,7 @@ for o in D.objects: for strip in track.strips: anims.append(strip.action) print(f"Writing {len(anims)} animations") - assert(len(anims) == 1) + assert len(anims) == 1, f"Expected the number of animations, {len(anims)}, to be 1, but it isn't" for animation in anims: armature.animation_data.action = animation startFrame = int(animation.frame_range.x) diff --git a/art/art.blend b/art/art.blend index da03571..a28eab4 100644 --- a/art/art.blend +++ b/art/art.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a01b027f3e3d00dcd39c735158953e1a8127b686a041d3ed9044d4a0cd857558 -size 13918948 +oid sha256:6c56a9e5611239a62ce5e78be3ea34eeb4bd380d6818d18c44323364ec1576dd +size 13965244 diff --git a/main.c b/main.c index 401c8c0..83f6914 100644 --- a/main.c +++ b/main.c @@ -1093,6 +1093,12 @@ Armature load_armature(MD_Arena *arena, MD_String8 binary_file, MD_String8 armat .pixel_format = SG_PIXELFORMAT_RGBA8, .min_filter = SG_FILTER_NEAREST, .mag_filter = SG_FILTER_NEAREST, + + // for webgl NPOT texures https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL + .wrap_u = SG_WRAP_CLAMP_TO_EDGE, + .wrap_v = SG_WRAP_CLAMP_TO_EDGE, + .wrap_w = SG_WRAP_CLAMP_TO_EDGE, + .usage = SG_USAGE_STREAM, }); @@ -1104,13 +1110,14 @@ Armature load_armature(MD_Arena *arena, MD_String8 binary_file, MD_String8 armat { for(int c = 0; c < 4; c++) { + const float eps = 0.0001f; if(r == c) { - assert(should_be_identity.Elements[c][r] == 1.0f); + assert(fabsf(should_be_identity.Elements[c][r] - 1.0f) < eps); } else { - assert(should_be_identity.Elements[c][r] == 0.0f); + assert(fabsf(should_be_identity.Elements[c][r] - 0.0f) < eps); } } } @@ -3075,8 +3082,8 @@ void init(void) mesh_player = load_mesh(persistent_arena, binary_file, MD_S8Lit("Player.bin")); - binary_file = MD_LoadEntireFile(frame_arena, MD_S8Lit("assets/exported_3d/Armature.bin")); - armature = load_armature(persistent_arena, binary_file, MD_S8Lit("Armature.bin")); + binary_file = MD_LoadEntireFile(frame_arena, MD_S8Lit("assets/exported_3d/WalkingArmature.bin")); + armature = load_armature(persistent_arena, binary_file, MD_S8Lit("WalkingArmature.bin")); @@ -4883,27 +4890,6 @@ void frame(void) Vec3 z = MulM4V3(cur->matrix_local, V3(0,0,cur->length)); Vec3 dot = MulM4V3(cur->matrix_local, V3(cur->length,0,cur->length)); - Vec3 should_be_zero = MulM4V3(cur->inverse_model_space_pos, from); - assert(should_be_zero.x == 0.0); - assert(should_be_zero.y == 0.0); - assert(should_be_zero.z == 0.0); - - if(cur->parent == 0) - { - // do some testing on the bone with no parent - Vec3 should_be_zero = MulM4V3(transform_to_mat(cur_pose_bone->parent_space_pose), V3(0,0,0)); - - // there is another bone, that's not at (0,0,0) in model space on the model - // for debugging purposes right now - - assert(should_be_zero.y == 0.0); - - /* - assert(should_be_zero.x == 0.0); - assert(should_be_zero.z == 0.0); - */ - } - // from, x, y, and z are like vertex points. They are model-space // points *around* the bones they should be influenced by. Now we // need to transform them according to how much the pose bones diff --git a/tuning.h b/tuning.h index 5079ba2..f2abcae 100644 --- a/tuning.h +++ b/tuning.h @@ -12,7 +12,7 @@ #define ARROW_SPEED 200.0f #define SECONDS_PER_ARROW 1.3f -#define ARENA_SIZE (1024*1024) +#define ARENA_SIZE (1024*1024*10) #define BIG_ARENA_SIZE (ARENA_SIZE * 8) #ifdef DEVTOOLS