summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/game_demo/game_demo.c20
-rw-r--r--examples/skinned_animation/ex_skinned_animation.c24
2 files changed, 25 insertions, 19 deletions
diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c
index 88de681..69023d7 100644
--- a/examples/game_demo/game_demo.c
+++ b/examples/game_demo/game_demo.c
@@ -117,20 +117,24 @@ int main() {
// Y Axis (blue)
Immdraw_Cone(transform_create(vec3(0.0, 2.0, 0.0), quat_ident(), vec3(0.3, 1.0, 0.3)),
vec4(0.0, 0.0, 1.0, 1.0), false);
- Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_ident(), vec3(thickness, 1.1, thickness)), vec4(0.0, 0.0, 1.0, 1.0),
- false);
+ Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_ident(), vec3(thickness, 1.1, thickness)),
+ vec4(0.0, 0.0, 1.0, 1.0), false);
// X Axis (green)
- Immdraw_Cone(transform_create(vec3(2.0, 0.0, 0.0), quat_from_axis_angle(VEC3_Z, HALF_PI, true), vec3(0.3, 1.0, 0.3)),
+ Immdraw_Cone(transform_create(vec3(2.0, 0.0, 0.0), quat_from_axis_angle(VEC3_Z, HALF_PI, true),
+ vec3(0.3, 1.0, 0.3)),
vec4(0.0, 1.0, 0.0, 1.0), false);
- Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_from_axis_angle(VEC3_Z, HALF_PI, true), vec3(thickness, 1.1, thickness)), vec4(0.0, 1.0, 0.0, 1.0),
- false);
+ Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_from_axis_angle(VEC3_Z, HALF_PI, true),
+ vec3(thickness, 1.1, thickness)),
+ vec4(0.0, 1.0, 0.0, 1.0), false);
// Z Axis (red)
- Immdraw_Cone(transform_create(vec3(0.0, 0.0, 2.0), quat_from_axis_angle(VEC3_X, -HALF_PI, true), vec3(0.3, 1.0, 0.3)),
+ Immdraw_Cone(transform_create(vec3(0.0, 0.0, 2.0), quat_from_axis_angle(VEC3_X, -HALF_PI, true),
+ vec3(0.3, 1.0, 0.3)),
vec4(1.0, 0.0, 0.0, 1.0), false);
- Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_from_axis_angle(VEC3_X, -HALF_PI, true), vec3(thickness, 1.1, thickness)), vec4(1.0, 0.0, 0.0, 1.0),
- false);
+ Immdraw_Cylinder(transform_create(VEC3_ZERO, quat_from_axis_angle(VEC3_X, -HALF_PI, true),
+ vec3(thickness, 1.1, thickness)),
+ vec4(1.0, 0.0, 0.0, 1.0), false);
if (draw_debug) {
// draw the player model with shadows
diff --git a/examples/skinned_animation/ex_skinned_animation.c b/examples/skinned_animation/ex_skinned_animation.c
index e1ebd64..81642ae 100644
--- a/examples/skinned_animation/ex_skinned_animation.c
+++ b/examples/skinned_animation/ex_skinned_animation.c
@@ -15,7 +15,7 @@
int main() {
double currentFrame = glfwGetTime();
double lastFrame = currentFrame;
- double deltaTime;
+ double delta_time;
Core_Bringup("Skinned Animation", NULL);
@@ -40,7 +40,7 @@ int main() {
// scene our_scene = make_default_scene();
- Vec3 cam_pos = vec3_create(0, 1.2, 4);
+ Vec3 cam_pos = vec3_create(1.5, 2.2, 8);
Camera cam = Camera_Create(cam_pos, VEC3_NEG_Z, VEC3_Y, deg_to_rad(45.0));
SetCamera(cam);
@@ -50,18 +50,20 @@ int main() {
// animation
// animation_clip track = simple_skin->animations->data[0];
- // f64 total_time = 0.0;
+ CASSERT(AnimationClip_darray_len(simple_skin->animations) > 0);
+ AnimationClip track = simple_skin->animations->data[0];
+ f64 total_time = 0.0;
while (!ShouldExit()) {
Frame_Begin();
currentFrame = glfwGetTime();
- deltaTime = currentFrame - lastFrame;
+ delta_time = currentFrame - lastFrame;
lastFrame = currentFrame;
- // total_time += deltaTime;
+ total_time += delta_time;
// printf("delta time %f\n", deltaTime);
- // f64 t = fmod(total_time, track.rotation->max);
- // INFO("Total time: %f", t);
+ f64 t = fmod(total_time, track.channels->data[0].max);
+ INFO("Delta time %f Animation time: %f", delta_time, t);
// bone rotation
// Quat rot = animation_sample(track.rotation, t).rotation;
@@ -75,17 +77,17 @@ int main() {
Mesh* m = Mesh_Get(simple_skin->meshes[0]);
RenderEnt render_ents[1] = { (RenderEnt){ .mesh = simple_skin->meshes[0],
.material = m->material,
- .animation_clip = simple_skin->animations->data[0],
- .is_playing = true,
- .t = 0.0,
+ .armature = &m->armature,
.affine = mat4_ident(),
.flags = 0 } };
// ModelExtractRenderEnts(rend_ents, handle, mat4_translation(vec3(0, 0, 0)), 0);
// draw_skinned_model(&core->renderer, &game.camera, simple_skin, tf, &our_scene);
+ Animation_Tick(&track, &m->armature, t);
+
Render_RenderEntities(render_ents, 1);
- // Animation_VisualiseJoints(&m->armature);
+ Animation_VisualiseJoints(&m->armature);
RenderEnt_darray_clear(rend_ents);