From: Javier Sancho Date: Sat, 11 Apr 2020 11:08:38 +0000 (+0200) Subject: set-animation-speed! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=db41186ef83fe5def23e3eacfbcea9248adf700e;p=guile-irrlicht.git set-animation-speed! --- diff --git a/src/animated-mesh.cpp b/src/animated-mesh.cpp index 9f461a2..327deb0 100644 --- a/src/animated-mesh.cpp +++ b/src/animated-mesh.cpp @@ -21,7 +21,10 @@ #include #include + #include "animated-mesh.h" +#include "animated-mesh-scene-node.h" +#include "gsubr.h" #include "wrapped.h" extern "C" { @@ -30,10 +33,34 @@ extern "C" { init_animated_mesh (void) { init_animated_mesh_type (); + DEFINE_GSUBR ("set-animation-speed!", 2, 0, 0, irr_scene_setAnimationSpeed); } DEFINE_WRAPPED_TYPE (irr::scene::IAnimatedMesh*, "animated-mesh", init_animated_mesh_type, animated_mesh_p, wrap_animated_mesh, unwrap_animated_mesh); + SCM + irr_scene_setAnimationSpeed (SCM wrapped_obj, + SCM frames_per_second) + { +#define SET_ANIMATION_SPEED(OBJ) OBJ->setAnimationSpeed (scm_to_double (frames_per_second)); + + if (animated_mesh_p (wrapped_obj)) + { + SET_ANIMATION_SPEED (unwrap_animated_mesh (wrapped_obj)); + } + else if (animated_mesh_scene_node_p (wrapped_obj)) + { + SET_ANIMATION_SPEED (unwrap_animated_mesh_scene_node (wrapped_obj)); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set animation speed to object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + + return SCM_UNSPECIFIED; + } + } diff --git a/src/animated-mesh.h b/src/animated-mesh.h index f063b39..4798c31 100644 --- a/src/animated-mesh.h +++ b/src/animated-mesh.h @@ -33,6 +33,11 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::scene::IAnimatedMesh*, init_animated_mesh_type, animated_mesh_p, wrap_animated_mesh, unwrap_animated_mesh); + + SCM + irr_scene_setAnimationSpeed (SCM wrapped_obj, + SCM frames_per_second); + } #endif