]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/guile-irrlicht.cpp
get-id
[guile-irrlicht.git] / src / guile-irrlicht.cpp
index f81cff7c73730aeba74dc477fd5c8496da62b8f9..7ea6f7ac7ea3ec7bbdac787cdf6f4640af1f303e 100644 (file)
 #include "cursor-control.h"
 #include "device.h"
 #include "event-receiver.h"
-#include "file-archive.h"
-#include "file-system.h"
+#include "file-list.h"
+#include "gsubr.h"
+#include "gui.h"
 #include "gui-element.h"
 #include "gui-environment.h"
-#include "gui-static-text.h"
 #include "guile-irrlicht.h"
+#include "io.h"
 #include "keymap.h"
 #include "material.h"
-#include "material-flags.h"
 #include "mesh.h"
 #include "mesh-scene-node.h"
 #include "reference-counted.h"
@@ -44,6 +44,7 @@
 #include "scene-node.h"
 #include "scene-node-animator.h"
 #include "texture.h"
+#include "timer.h"
 #include "vertex3d.h"
 #include "video-driver.h"
 #include "wchar.h"
@@ -61,14 +62,10 @@ extern "C" {
     init_cursor_control ();
     init_device ();
     init_event_receiver ();
-    init_file_archive ();
-    init_file_system ();
-    init_gui_element ();
-    init_gui_environment ();
-    init_gui_static_text ();
+    init_gui ();
+    init_io ();
     init_keymap ();
     init_material ();
-    init_material_flag ();
     init_mesh ();
     init_mesh_scene_node ();
     init_reference_counted ();
@@ -76,17 +73,19 @@ extern "C" {
     init_scene_node ();
     init_scene_node_animator ();
     init_texture ();
+    init_timer ();
     init_vertex3d ();
     init_video_driver ();
 
     // Shared procedures (used by two or more objects)
-    scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll);
-    scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName);
-    scm_c_define_gsubr ("set-material!", 2, 0, 0, (scm_t_subr)irr_setMaterial);
-    scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition);
-    scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible);
-    scm_c_export ("draw-all", "get-name", "set-material!", "set-position!",
-                  "set-visible!", NULL);
+    DEFINE_GSUBR ("draw-all", 1, 0, 0, irr_drawAll);
+    DEFINE_GSUBR ("get-id", 1, 1, 0, irr_getID);
+    DEFINE_GSUBR ("get-name", 1, 0, 0, irr_getName);
+    DEFINE_GSUBR ("get-position", 1, 1, 0, irr_getPosition);
+    DEFINE_GSUBR ("set-material!", 2, 0, 0, irr_setMaterial);
+    DEFINE_GSUBR ("set-material-flag!", 3, 0, 0, irr_setMaterialFlag);
+    DEFINE_GSUBR ("set-position!", 2, 0, 0, irr_setPosition);
+    DEFINE_GSUBR ("set-visible!", 2, 0, 0, irr_setVisible);
   }
 
   SCM
@@ -108,6 +107,29 @@ extern "C" {
     return SCM_UNSPECIFIED;
   }
 
+  SCM
+  irr_getID (SCM wrapped_obj,
+             SCM index)
+  {
+    if (file_list_p (wrapped_obj))
+      {
+        return scm_from_uint32 (unwrap_file_list (wrapped_obj)->getID (scm_to_uint32 (index)));
+      }
+    else if (gui_element_p (wrapped_obj))
+      {
+        return scm_from_int32 (unwrap_gui_element (wrapped_obj)->getID ());
+      }
+    else if (scene_node_p (wrapped_obj))
+      {
+        return scm_from_int32 (unwrap_scene_node (wrapped_obj)->getID ());
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot get id from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+  }
+
   SCM
   irr_getName (SCM wrapped_obj)
   {
@@ -122,6 +144,25 @@ extern "C" {
       }
   }
 
+  SCM
+  irr_getPosition (SCM wrapped_obj,
+                   SCM i)
+  {
+    if (cursor_control_p (wrapped_obj))
+      {
+        return irr_gui_getPosition (wrapped_obj);
+      }
+    else if (is_scene_node_object (wrapped_obj))
+      {
+        return irr_scene_getPosition (wrapped_obj);
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot get position from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+  }
+
   SCM
   irr_setMaterial (SCM wrapped_obj,
                    SCM material)
@@ -137,6 +178,22 @@ extern "C" {
       }
   }
 
+  SCM
+  irr_setMaterialFlag (SCM wrapped_obj,
+                       SCM flag,
+                       SCM newvalue)
+  {
+    if (is_scene_node_object (wrapped_obj))
+      {
+        return irr_scene_ISceneNode_setMaterialFlag (wrapped_obj, flag, newvalue);
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set material flag to object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+  }
+
   SCM
   irr_setPosition (SCM wrapped_obj,
                    SCM position)
@@ -145,13 +202,13 @@ extern "C" {
       {
         return irr_gui_setPosition (wrapped_obj, position);
       }
-    else if (scene_node_p (wrapped_obj) || mesh_scene_node_p (wrapped_obj))
+    else if (is_scene_node_object (wrapped_obj))
       {
         return irr_scene_setPosition (wrapped_obj, position);
       }
     else
       {
-        scm_error (scm_arg_type_key, NULL, "Cannot set position for object: ~S",
+        scm_error (scm_arg_type_key, NULL, "Cannot set position to object: ~S",
                    scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
       }
   }
@@ -160,21 +217,23 @@ extern "C" {
   irr_setVisible (SCM wrapped_obj,
                   SCM visible)
   {
+#define SET_VISIBLE(OBJ) OBJ->setVisible (scm_to_bool (visible));
+
     if (cursor_control_p (wrapped_obj))
       {
-        unwrap_cursor_control (wrapped_obj)->setVisible (scm_to_bool (visible));
+        SET_VISIBLE (unwrap_cursor_control (wrapped_obj));
       }
     else if (gui_element_p (wrapped_obj))
       {
-        unwrap_gui_element (wrapped_obj)->setVisible (scm_to_bool (visible));
+        SET_VISIBLE (unwrap_gui_element (wrapped_obj));
       }
-    else if (scene_node_p (wrapped_obj))
+    else if (is_scene_node_object (wrapped_obj))
       {
-        unwrap_scene_node (wrapped_obj)->setVisible (scm_to_bool (visible));
+        SET_VISIBLE (unwrap_scene_node (wrapped_obj));
       }
     else
       {
-        scm_error (scm_arg_type_key, NULL, "Cannot set visibility for object: ~S",
+        scm_error (scm_arg_type_key, NULL, "Cannot set visibility to object: ~S",
                    scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
       }
     return SCM_UNSPECIFIED;