]> git.jsancho.org Git - guile-irrlicht.git/blob - src/scene-node.cpp
Some doc
[guile-irrlicht.git] / src / scene-node.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 "gsubr.h"
25 #include "material-flags.h"
26 #include "matrix4.h"
27 #include "scene-node.h"
28 #include "vector3d.h"
29 #include "wrapped.h"
30
31 using namespace irr;
32
33 template <typename TSceneNode>
34 SCM
35 ISceneNode_addAnimator (SCM scene_node,
36                         SCM animator)
37 {
38   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
39   node->addAnimator ((scene::ISceneNodeAnimator*) scm_to_irr_pointer (animator));
40   return SCM_UNSPECIFIED;
41 }
42
43 template <typename TSceneNode>
44 SCM
45 ISceneNode_getAbsoluteTransformation (SCM scene_node)
46 {
47   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
48   return scm_from_matrix4 (node->getAbsoluteTransformation ());
49 }
50
51 template <typename TSceneNode>
52 SCM
53 ISceneNode_getPosition (SCM scene_node)
54 {
55   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
56   return scm_from_vector3df (node->getPosition ());
57 }
58
59 template <typename TSceneNode>
60 SCM
61 ISceneNode_setMaterialFlag (SCM scene_node,
62                             SCM flag,
63                             SCM newvalue)
64 {
65   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
66   node->setMaterialFlag (scm_to_material_flag (flag), scm_to_bool (newvalue));
67   return SCM_UNSPECIFIED;
68 }
69
70 template <typename TSceneNode>
71 SCM
72 ISceneNode_setMaterialTexture (SCM scene_node,
73                                SCM texture_layer,
74                                SCM texture)
75 {
76   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
77   node->setMaterialTexture (scm_to_uint32 (texture_layer),
78                             (video::ITexture*) scm_to_irr_pointer (texture));
79   return SCM_UNSPECIFIED;
80 }
81
82 template <typename TSceneNode>
83 SCM
84 ISceneNode_setPosition (SCM scene_node,
85                         SCM position)
86 {
87   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
88   node->setPosition (scm_to_vector3df (position));
89   return SCM_UNSPECIFIED;
90 }
91
92 template <typename TSceneNode>
93 SCM
94 ISceneNode_setRotation (SCM scene_node,
95                         SCM rotation)
96 {
97   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
98   node->setRotation (scm_to_vector3df (rotation));
99   return SCM_UNSPECIFIED;
100 }
101
102 template <typename TSceneNode>
103 SCM
104 ISceneNode_setScale (SCM scene_node,
105                      SCM scale)
106 {
107   TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node);
108   node->setScale (scm_to_vector3df (scale));
109   return SCM_UNSPECIFIED;
110 }
111
112 void
113 init_scene_node (void)
114 {
115   DEFINE_GSUBR ("IAnimatedMeshSceneNode_addAnimator", 2, 0, 0,
116                 ISceneNode_addAnimator<scene::IAnimatedMeshSceneNode*>);
117   DEFINE_GSUBR ("IMeshSceneNode_addAnimator", 2, 0, 0,
118                 ISceneNode_addAnimator<scene::IMeshSceneNode*>);
119   DEFINE_GSUBR ("ISceneNode_addAnimator", 2, 0, 0,
120                 ISceneNode_addAnimator<scene::ISceneNode*>);
121
122   DEFINE_GSUBR ("ISceneNode_getAbsoluteTransformation", 1, 0, 0,
123                 ISceneNode_getAbsoluteTransformation<scene::ISceneNode*>);
124
125   DEFINE_GSUBR ("IMeshSceneNode_getPosition", 1, 0, 0,
126                 ISceneNode_getPosition<scene::IMeshSceneNode*>);
127   DEFINE_GSUBR ("ISceneNode_getPosition", 1, 0, 0,
128                 ISceneNode_getPosition<scene::ISceneNode*>);
129
130   DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialFlag", 3, 0, 0,
131                 ISceneNode_setMaterialFlag<scene::IAnimatedMeshSceneNode*>);
132   DEFINE_GSUBR ("IMeshSceneNode_setMaterialFlag", 3, 0, 0,
133                 ISceneNode_setMaterialFlag<scene::IMeshSceneNode*>);
134   DEFINE_GSUBR ("ISceneNode_setMaterialFlag", 3, 0, 0,
135                 ISceneNode_setMaterialFlag<scene::ISceneNode*>);
136
137   DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialTexture", 3, 0, 0,
138                 ISceneNode_setMaterialTexture<scene::IAnimatedMeshSceneNode*>);
139   DEFINE_GSUBR ("IMeshSceneNode_setMaterialTexture", 3, 0, 0,
140                 ISceneNode_setMaterialTexture<scene::IMeshSceneNode*>);
141   DEFINE_GSUBR ("ISceneNode_setMaterialTexture", 3, 0, 0,
142                 ISceneNode_setMaterialTexture<scene::ISceneNode*>);
143
144   DEFINE_GSUBR ("IMeshSceneNode_setPosition", 2, 0, 0,
145                 ISceneNode_setPosition<scene::IMeshSceneNode*>);
146   DEFINE_GSUBR ("ISceneNode_setPosition", 2, 0, 0,
147                 ISceneNode_setPosition<scene::ISceneNode*>);
148
149   DEFINE_GSUBR ("IAnimatedMeshSceneNode_setRotation", 2, 0, 0,
150                 ISceneNode_setRotation<scene::IAnimatedMeshSceneNode*>);
151   DEFINE_GSUBR ("ICameraSceneNode_setRotation", 2, 0, 0,
152                 ISceneNode_setRotation<scene::ICameraSceneNode*>);
153   DEFINE_GSUBR ("ISceneNode_setRotation", 2, 0, 0,
154                 ISceneNode_setRotation<scene::ISceneNode*>);
155
156   DEFINE_GSUBR ("IAnimatedMeshSceneNode_setScale", 2, 0, 0,
157                 ISceneNode_setScale<scene::IAnimatedMeshSceneNode*>);
158   DEFINE_GSUBR ("ISceneNode_setScale", 2, 0, 0,
159                 ISceneNode_setScale<scene::ISceneNode*>);
160 }