]> git.jsancho.org Git - guile-irrlicht.git/blob - src/scene-manager.cpp
rename files
[guile-irrlicht.git] / src / scene-manager.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
25 #include "animated-mesh.h"
26 #include "animated-mesh-scene-node.h"
27 #include "scene-manager.h"
28 #include "scene-node.h"
29 #include "vector3d.h"
30 #include "wrapped.h"
31
32 extern "C" {
33
34   void
35   init_scene_manager (void)
36   {
37     init_scene_manager_type ();
38     scm_c_define_gsubr ("add-animated-mesh-scene-node", 8, 0, 0,
39                         (scm_t_subr)irr_scene_addAnimatedMeshSceneNode);
40     scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh);
41   }
42
43   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
44                        init_scene_manager_type, scene_manager_p,
45                        wrap_scene_manager, unwrap_scene_manager);
46
47   SCM
48   irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
49                                       SCM mesh,
50                                       SCM parent,
51                                       SCM id,
52                                       SCM position,
53                                       SCM rotation,
54                                       SCM scale,
55                                       SCM alsoAddIfMeshPointerZero)
56   {
57     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
58     irr::scene::IAnimatedMeshSceneNode* node =
59       smgr->addAnimatedMeshSceneNode (unwrap_animated_mesh (mesh),
60                                       scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
61                                       scm_to_int32 (id),
62                                       scm_to_vector3df (position),
63                                       scm_to_vector3df (rotation),
64                                       scm_to_vector3df (scale),
65                                       scm_to_bool (alsoAddIfMeshPointerZero));
66     return wrap_animated_mesh_scene_node (node);
67   }
68
69   SCM
70   irr_scene_getMesh (SCM wrapped_scene_manager,
71                      SCM filename)
72   {
73     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
74     irr::scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_stringn (filename, NULL));
75     return wrap_animated_mesh (mesh);
76   }
77
78 }