fix formatting
This commit is contained in:
parent
d222955ac3
commit
216f5f4047
|
|
@ -35,7 +35,7 @@ int main(void)
|
|||
|
||||
// Loaf gltf model
|
||||
Model model = LoadModel("resources/models/gltf/robot.glb");
|
||||
unsigned int animsCount;
|
||||
unsigned int animsCount = 0;
|
||||
ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/robot.glb", &animsCount);
|
||||
|
||||
unsigned int animIndex = 0;
|
||||
|
|
@ -58,6 +58,7 @@ int main(void)
|
|||
if (IsKeyPressed(KEY_UP)) {
|
||||
animIndex = (animIndex + 1) % animsCount;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_DOWN)) {
|
||||
animIndex = (animIndex + animsCount - 1) % animsCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4703,6 +4703,7 @@ static BoneInfo *LoadGLTFBoneInfo(cgltf_skin skin, int *boneCount) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bones[i].parent = parentIndex;
|
||||
}
|
||||
|
||||
|
|
@ -5182,19 +5183,19 @@ static void GetGLTFPoseAtTime(cgltf_accessor* input, cgltf_accessor *output, flo
|
|||
cgltf_bool r2 = cgltf_accessor_read_float(input, i+1, &tend, 1);
|
||||
assert(r2);
|
||||
|
||||
if(tstart <= time && time < tend) {
|
||||
if ((tstart <= time) && (time < tend)) {
|
||||
keyframe = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float t = (time - tstart)/(tend - tstart);
|
||||
t = t < 0 ? 0 : t;
|
||||
t = t > 1 ? 1 : t;
|
||||
t = (t < 0)? 0 : t;
|
||||
t = (t > 1)? 1 : t;
|
||||
|
||||
assert(output->component_type == cgltf_component_type_r_32f);
|
||||
if (output->type == cgltf_type_vec3) {
|
||||
float tmp[3];
|
||||
float tmp[3] = { 0 };
|
||||
cgltf_accessor_read_float(output, keyframe, tmp, 3);
|
||||
Vector3 v1 = {tmp[0], tmp[1], tmp[2]};
|
||||
cgltf_accessor_read_float(output, keyframe+1, tmp, 3);
|
||||
|
|
@ -5202,7 +5203,7 @@ static void GetGLTFPoseAtTime(cgltf_accessor* input, cgltf_accessor *output, flo
|
|||
Vector3 *r = data;
|
||||
*r = Vector3Lerp(v1, v2, t);
|
||||
} else if (output->type == cgltf_type_vec4) {
|
||||
float tmp[4];
|
||||
float tmp[4] = { 0 };
|
||||
cgltf_accessor_read_float(output, keyframe, tmp, 4);
|
||||
Vector4 v1 = {tmp[0], tmp[1], tmp[2], tmp[3]};
|
||||
cgltf_accessor_read_float(output, keyframe+1, tmp, 4);
|
||||
|
|
@ -5260,6 +5261,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (boneIndex == -1) {
|
||||
// animation channel for a node not in the armature.
|
||||
continue;
|
||||
|
|
@ -5277,12 +5279,11 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in
|
|||
}
|
||||
} else TRACELOG(LOG_WARNING, "MODEL: [%s] Only linear interpolation curves are supported for GLTF animation.", fileName);
|
||||
|
||||
|
||||
float t;
|
||||
cgltf_bool r = cgltf_accessor_read_float(channel.sampler->input, channel.sampler->input->count - 1, &t, 1);
|
||||
assert(r);
|
||||
|
||||
animDuration = t > animDuration ? t : animDuration;
|
||||
animDuration = (t > animDuration)? t : animDuration;
|
||||
}
|
||||
|
||||
animations[i].frameCount = (int)(animDuration*1000/GLTF_ANIMDELAY);
|
||||
|
|
@ -5321,6 +5322,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in
|
|||
.rotation = rotation,
|
||||
.scale = scale};
|
||||
}
|
||||
|
||||
BuildPoseFromParentJoints(animations[i].bones, animations[i].boneCount, animations[i].framePoses[j]);
|
||||
}
|
||||
|
||||
|
|
@ -5328,6 +5330,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in
|
|||
RL_FREE(boneChannels);
|
||||
}
|
||||
} else TRACELOG(LOG_ERROR, "MODEL: [%s] expected exactly one skin to load animation data from, but found %i", fileName, data->skins_count);
|
||||
|
||||
cgltf_free(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user