1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
3 Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
5 This file is part of guile-irrlicht.
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.
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.
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/>.
22 #include <irrlicht/irrlicht.h>
25 #include "material-flags.h"
27 #include "scene-node.h"
34 template <typename TSceneNode>
36 ISceneNode_addAnimator (SCM scene_node,
39 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
40 node->addAnimator ((scene::ISceneNodeAnimator*) scm_to_pointer (animator));
41 return SCM_UNSPECIFIED;
45 template <typename TSceneNode>
47 ISceneNode_getAbsoluteTransformation (SCM scene_node)
49 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
50 return scm_from_matrix4 (node->getAbsoluteTransformation ());
54 template <typename TSceneNode>
56 ISceneNode_getPosition (SCM scene_node)
58 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
59 return scm_from_vector3df (node->getPosition ());
63 template <typename TSceneNode>
65 ISceneNode_setMaterialFlag (SCM scene_node,
69 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
70 node->setMaterialFlag (scm_to_material_flag (flag), scm_to_bool (newvalue));
71 return SCM_UNSPECIFIED;
75 template <typename TSceneNode>
77 ISceneNode_setMaterialTexture (SCM scene_node,
81 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
82 node->setMaterialTexture (scm_to_uint32 (texture_layer),
83 (video::ITexture*) scm_to_pointer (texture));
84 return SCM_UNSPECIFIED;
88 template <typename TSceneNode>
90 ISceneNode_setPosition (SCM scene_node,
93 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
94 node->setPosition (scm_to_vector3df (position));
95 return SCM_UNSPECIFIED;
99 template <typename TSceneNode>
101 ISceneNode_setRotation (SCM scene_node,
104 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
105 node->setRotation (scm_to_vector3df (rotation));
106 return SCM_UNSPECIFIED;
110 template <typename TSceneNode>
112 ISceneNode_setScale (SCM scene_node,
115 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
116 node->setScale (scm_to_vector3df (scale));
117 return SCM_UNSPECIFIED;
124 init_scene_node (void)
126 DEFINE_GSUBR ("IAnimatedMeshSceneNode_addAnimator", 2, 0, 0,
127 ISceneNode_addAnimator<scene::IAnimatedMeshSceneNode*>);
128 DEFINE_GSUBR ("IMeshSceneNode_addAnimator", 2, 0, 0,
129 ISceneNode_addAnimator<scene::IMeshSceneNode*>);
130 DEFINE_GSUBR ("ISceneNode_addAnimator", 2, 0, 0,
131 ISceneNode_addAnimator<scene::ISceneNode*>);
133 DEFINE_GSUBR ("ISceneNode_getAbsoluteTransformation", 1, 0, 0,
134 ISceneNode_getAbsoluteTransformation<scene::ISceneNode*>);
136 DEFINE_GSUBR ("IMeshSceneNode_getPosition", 1, 0, 0,
137 ISceneNode_getPosition<scene::IMeshSceneNode*>);
138 DEFINE_GSUBR ("ISceneNode_getPosition", 1, 0, 0,
139 ISceneNode_getPosition<scene::ISceneNode*>);
141 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialFlag", 3, 0, 0,
142 ISceneNode_setMaterialFlag<scene::IAnimatedMeshSceneNode*>);
143 DEFINE_GSUBR ("IMeshSceneNode_setMaterialFlag", 3, 0, 0,
144 ISceneNode_setMaterialFlag<scene::IMeshSceneNode*>);
145 DEFINE_GSUBR ("ISceneNode_setMaterialFlag", 3, 0, 0,
146 ISceneNode_setMaterialFlag<scene::ISceneNode*>);
148 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialTexture", 3, 0, 0,
149 ISceneNode_setMaterialTexture<scene::IAnimatedMeshSceneNode*>);
150 DEFINE_GSUBR ("IMeshSceneNode_setMaterialTexture", 3, 0, 0,
151 ISceneNode_setMaterialTexture<scene::IMeshSceneNode*>);
152 DEFINE_GSUBR ("ISceneNode_setMaterialTexture", 3, 0, 0,
153 ISceneNode_setMaterialTexture<scene::ISceneNode*>);
155 DEFINE_GSUBR ("IMeshSceneNode_setPosition", 2, 0, 0,
156 ISceneNode_setPosition<scene::IMeshSceneNode*>);
157 DEFINE_GSUBR ("ISceneNode_setPosition", 2, 0, 0,
158 ISceneNode_setPosition<scene::ISceneNode*>);
160 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setRotation", 2, 0, 0,
161 ISceneNode_setRotation<scene::IAnimatedMeshSceneNode*>);
162 DEFINE_GSUBR ("ICameraSceneNode_setRotation", 2, 0, 0,
163 ISceneNode_setRotation<scene::ICameraSceneNode*>);
164 DEFINE_GSUBR ("ISceneNode_setRotation", 2, 0, 0,
165 ISceneNode_setRotation<scene::ISceneNode*>);
167 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setScale", 2, 0, 0,
168 ISceneNode_setScale<scene::IAnimatedMeshSceneNode*>);
169 DEFINE_GSUBR ("ISceneNode_setScale", 2, 0, 0,
170 ISceneNode_setScale<scene::ISceneNode*>);