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"
32 template <typename TSceneNode>
34 ISceneNode_addAnimator (SCM scene_node,
37 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
38 node->addAnimator ((scene::ISceneNodeAnimator*) scm_to_pointer (animator));
39 return SCM_UNSPECIFIED;
42 template <typename TSceneNode>
44 ISceneNode_getAbsoluteTransformation (SCM scene_node)
46 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
47 return scm_from_matrix4 (node->getAbsoluteTransformation ());
50 template <typename TSceneNode>
52 ISceneNode_getPosition (SCM scene_node)
54 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
55 return scm_from_vector3df (node->getPosition ());
58 template <typename TSceneNode>
60 ISceneNode_setMaterialFlag (SCM scene_node,
64 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
65 node->setMaterialFlag (scm_to_material_flag (flag), scm_to_bool (newvalue));
66 return SCM_UNSPECIFIED;
69 template <typename TSceneNode>
71 ISceneNode_setMaterialTexture (SCM scene_node,
75 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
76 node->setMaterialTexture (scm_to_uint32 (texture_layer),
77 (video::ITexture*) scm_to_pointer (texture));
78 return SCM_UNSPECIFIED;
81 template <typename TSceneNode>
83 ISceneNode_setPosition (SCM scene_node,
86 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
87 node->setPosition (scm_to_vector3df (position));
88 return SCM_UNSPECIFIED;
91 template <typename TSceneNode>
93 ISceneNode_setRotation (SCM scene_node,
96 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
97 node->setRotation (scm_to_vector3df (rotation));
98 return SCM_UNSPECIFIED;
101 template <typename TSceneNode>
103 ISceneNode_setScale (SCM scene_node,
106 TSceneNode node = (TSceneNode) scm_to_pointer (scene_node);
107 node->setScale (scm_to_vector3df (scale));
108 return SCM_UNSPECIFIED;
112 init_scene_node (void)
114 DEFINE_GSUBR ("IAnimatedMeshSceneNode_addAnimator", 2, 0, 0,
115 ISceneNode_addAnimator<scene::IAnimatedMeshSceneNode*>);
116 DEFINE_GSUBR ("IMeshSceneNode_addAnimator", 2, 0, 0,
117 ISceneNode_addAnimator<scene::IMeshSceneNode*>);
118 DEFINE_GSUBR ("ISceneNode_addAnimator", 2, 0, 0,
119 ISceneNode_addAnimator<scene::ISceneNode*>);
121 DEFINE_GSUBR ("ISceneNode_getAbsoluteTransformation", 1, 0, 0,
122 ISceneNode_getAbsoluteTransformation<scene::ISceneNode*>);
124 DEFINE_GSUBR ("IMeshSceneNode_getPosition", 1, 0, 0,
125 ISceneNode_getPosition<scene::IMeshSceneNode*>);
126 DEFINE_GSUBR ("ISceneNode_getPosition", 1, 0, 0,
127 ISceneNode_getPosition<scene::ISceneNode*>);
129 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialFlag", 3, 0, 0,
130 ISceneNode_setMaterialFlag<scene::IAnimatedMeshSceneNode*>);
131 DEFINE_GSUBR ("IMeshSceneNode_setMaterialFlag", 3, 0, 0,
132 ISceneNode_setMaterialFlag<scene::IMeshSceneNode*>);
133 DEFINE_GSUBR ("ISceneNode_setMaterialFlag", 3, 0, 0,
134 ISceneNode_setMaterialFlag<scene::ISceneNode*>);
136 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialTexture", 3, 0, 0,
137 ISceneNode_setMaterialTexture<scene::IAnimatedMeshSceneNode*>);
138 DEFINE_GSUBR ("IMeshSceneNode_setMaterialTexture", 3, 0, 0,
139 ISceneNode_setMaterialTexture<scene::IMeshSceneNode*>);
140 DEFINE_GSUBR ("ISceneNode_setMaterialTexture", 3, 0, 0,
141 ISceneNode_setMaterialTexture<scene::ISceneNode*>);
143 DEFINE_GSUBR ("IMeshSceneNode_setPosition", 2, 0, 0,
144 ISceneNode_setPosition<scene::IMeshSceneNode*>);
145 DEFINE_GSUBR ("ISceneNode_setPosition", 2, 0, 0,
146 ISceneNode_setPosition<scene::ISceneNode*>);
148 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setRotation", 2, 0, 0,
149 ISceneNode_setRotation<scene::IAnimatedMeshSceneNode*>);
150 DEFINE_GSUBR ("ICameraSceneNode_setRotation", 2, 0, 0,
151 ISceneNode_setRotation<scene::ICameraSceneNode*>);
152 DEFINE_GSUBR ("ISceneNode_setRotation", 2, 0, 0,
153 ISceneNode_setRotation<scene::ISceneNode*>);
155 DEFINE_GSUBR ("IAnimatedMeshSceneNode_setScale", 2, 0, 0,
156 ISceneNode_setScale<scene::IAnimatedMeshSceneNode*>);
157 DEFINE_GSUBR ("ISceneNode_setScale", 2, 0, 0,
158 ISceneNode_setScale<scene::ISceneNode*>);