]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/scene-node.cpp
set-material-texture! get-texture
[guile-irrlicht.git] / src / scene-node.cpp
index d392aba5200a332fe60ff4c25018723f8f4b16b6..16ddbf6a7fab932d9c9a396b82147f2913ecc5aa 100644 (file)
@@ -21,7 +21,9 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
+#include "animated-mesh-scene-node.h"
 #include "scene-node.h"
+#include "texture.h"
 #include "wrapped.h"
 
 extern "C" {
@@ -30,10 +32,36 @@ extern "C" {
   init_scene_node (void)
   {
     init_scene_node_type ();
+    scm_c_define_gsubr ("set-material-texture!", 3, 0, 0, (scm_t_subr)irr_scene_setMaterialTexture);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node",
                        init_scene_node_type, scene_node_p,
                        wrap_scene_node, unwrap_scene_node);
 
+  SCM
+  irr_scene_setMaterialTexture (SCM wrapped_scene_node,
+                                SCM texture_layer,
+                                SCM texture)
+  {
+    if (animated_mesh_scene_node_p (wrapped_scene_node))
+      {
+        unwrap_animated_mesh_scene_node (wrapped_scene_node)->
+          setMaterialTexture (scm_to_uint32 (texture_layer),
+                              unwrap_texture (texture));
+      }
+    else if (scene_node_p (wrapped_scene_node))
+      {
+        unwrap_scene_node (wrapped_scene_node)->
+          setMaterialTexture (scm_to_uint32 (texture_layer),
+                              unwrap_texture (texture));
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set material texture to object: ~S",
+                   scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
+      }
+    return SCM_UNSPECIFIED;
+  }
+
 }