From cda40baa72c6a0b5a5b4aee503b1395fa4b8ede2 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 29 Mar 2020 20:26:54 +0200 Subject: [PATCH] create-rotation-animator --- Makefile.am | 1 + src/guile-irrlicht.cpp | 2 ++ src/scene-manager.cpp | 16 ++++++++++++++- src/scene-manager.h | 4 ++++ src/scene-node-animator.cpp | 39 ++++++++++++++++++++++++++++++++++++ src/scene-node-animator.h | 40 +++++++++++++++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/scene-node-animator.cpp create mode 100644 src/scene-node-animator.h diff --git a/Makefile.am b/Makefile.am index b2fc266..43eb9c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,6 +50,7 @@ libguile_irrlicht_la_SOURCES = \ src/reference-counted.cpp \ src/scene-manager.cpp \ src/scene-node.cpp \ + src/scene-node-animator.cpp \ src/texture.cpp \ src/vector2d.cpp \ src/vector3d.cpp \ diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index 6e7a937..1bb87cf 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -41,6 +41,7 @@ #include "reference-counted.h" #include "scene-manager.h" #include "scene-node.h" +#include "scene-node-animator.h" #include "texture.h" #include "vertex3d.h" #include "video-driver.h" @@ -70,6 +71,7 @@ extern "C" { init_reference_counted (); init_scene_manager (); init_scene_node (); + init_scene_node_animator (); init_texture (); init_vertex3d (); init_video_driver (); diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index da5425a..f5d1bf7 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -33,6 +33,7 @@ #include "mesh-scene-node.h" #include "scene-manager.h" #include "scene-node.h" +#include "scene-node-animator.h" #include "vector3d.h" #include "wrapped.h" @@ -52,12 +53,15 @@ extern "C" { (scm_t_subr)irr_scene_addCustomSceneNode); scm_c_define_gsubr ("add-octree-scene-node!", 2, 0, 1, (scm_t_subr)irr_scene_addOctreeSceneNode); + scm_c_define_gsubr ("create-rotation-animator", 2, 0, 0, + (scm_t_subr)irr_scene_createRotationAnimator); scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh); scm_c_define_gsubr ("get-root-scene-node", 1, 0, 0, (scm_t_subr)irr_scene_getRootSceneNode); scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager); scm_c_export ("add-animated-mesh-scene-node!", "add-camera-scene-node!", "add-camera-scene-node-fps!", "add-custom-scene-node!", - "add-octree-scene-node!", "get-mesh", "get-root-scene-node", + "add-octree-scene-node!", "create-rotation-animator", + "get-mesh", "get-root-scene-node", "get-scene-manager", NULL); } @@ -319,6 +323,16 @@ extern "C" { return wrap_mesh_scene_node (node); } + SCM + irr_scene_createRotationAnimator (SCM wrapped_scene_manager, + SCM rotation_speed) + { + irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager); + irr::scene::ISceneNodeAnimator* anim = + smgr->createRotationAnimator(scm_to_vector3df (rotation_speed)); + return wrap_scene_node_animator (anim); + } + SCM irr_scene_getMesh (SCM wrapped_scene_manager, SCM filename) diff --git a/src/scene-manager.h b/src/scene-manager.h index b4a099d..5da8358 100644 --- a/src/scene-manager.h +++ b/src/scene-manager.h @@ -60,6 +60,10 @@ extern "C" { SCM wrapped_mesh, SCM rest); + SCM + irr_scene_createRotationAnimator (SCM wrapped_scene_manager, + SCM rotation_speed); + SCM irr_scene_getMesh (SCM wrapped_scene_manager, SCM filename); diff --git a/src/scene-node-animator.cpp b/src/scene-node-animator.cpp new file mode 100644 index 0000000..440fd4a --- /dev/null +++ b/src/scene-node-animator.cpp @@ -0,0 +1,39 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#include +#include +#include "scene-node-animator.h" +#include "wrapped.h" + +extern "C" { + + void + init_scene_node_animator (void) + { + init_scene_node_animator_type (); + } + + DEFINE_WRAPPED_TYPE (irr::scene::ISceneNodeAnimator*, "scene-node-animator", + init_scene_node_animator_type, scene_node_animator_p, + wrap_scene_node_animator, unwrap_scene_node_animator); + +} diff --git a/src/scene-node-animator.h b/src/scene-node-animator.h new file mode 100644 index 0000000..baddc1b --- /dev/null +++ b/src/scene-node-animator.h @@ -0,0 +1,40 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#ifndef __GUILE_IRRLICHT_SCENE_NODE_ANIMATOR_H_INCLUDED__ +#define __GUILE_IRRLICHT_SCENE_NODE_ANIMATOR_H_INCLUDED__ + +#include +#include +#include "wrapped.h" + +extern "C" { + + void + init_scene_node_animator (void); + + DECLARE_WRAPPED_TYPE (irr::scene::ISceneNodeAnimator*, init_scene_node_animator_type, + scene_node_animator_p, wrap_scene_node_animator, + unwrap_scene_node_animator); + +} + +#endif -- 2.39.5