]> git.jsancho.org Git - guile-irrlicht.git/blob - src/ISceneManager.cpp
drop refactor
[guile-irrlicht.git] / src / ISceneManager.cpp
1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
2
3    Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
4
5    This file is part of guile-irrlicht.
6
7    guile-irrlicht is free software; you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 3 of the
10    License, or (at your option) any later version.
11
12    guile-irrlicht is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with guile-irrlicht. If not, see
19    <http://www.gnu.org/licenses/>.
20 */
21
22 #include <irrlicht/irrlicht.h>
23 #include <libguile.h>
24 #include "IAnimatedMesh.h"
25 #include "IAnimatedMeshSceneNode.h"
26 #include "ISceneManager.h"
27 #include "ISceneNode.h"
28 #include "vector3d.h"
29 #include "wrapped.h"
30
31 extern "C" {
32
33   void
34   init_scene_manager (void)
35   {
36     init_scene_manager_type ();
37     scm_c_define_gsubr ("add-animated-mesh-scene-node", 8, 0, 0,
38                         (scm_t_subr)irr_scene_addAnimatedMeshSceneNode);
39     scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh);
40   }
41
42   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
43                        init_scene_manager_type, scene_manager_p,
44                        wrap_scene_manager, unwrap_scene_manager);
45
46   SCM
47   irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
48                                       SCM mesh,
49                                       SCM parent,
50                                       SCM id,
51                                       SCM position,
52                                       SCM rotation,
53                                       SCM scale,
54                                       SCM alsoAddIfMeshPointerZero)
55   {
56     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
57     irr::scene::IAnimatedMeshSceneNode* node =
58       smgr->addAnimatedMeshSceneNode (unwrap_animated_mesh (mesh),
59                                       scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
60                                       scm_to_int32 (id),
61                                       scm_to_vector3df (position),
62                                       scm_to_vector3df (rotation),
63                                       scm_to_vector3df (scale),
64                                       scm_to_bool (alsoAddIfMeshPointerZero));
65     return wrap_animated_mesh_scene_node (node);
66   }
67
68   SCM
69   irr_scene_getMesh (SCM wrapped_scene_manager,
70                      SCM filename)
71   {
72     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
73     irr::scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_stringn (filename, NULL));
74     return wrap_animated_mesh (mesh);
75   }
76
77 }