]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/scene-manager.cpp
Get irrlicht objects
[guile-irrlicht.git] / src / scene-manager.cpp
index 9ef592fcbfaa10972e78b68010cda494265d9632..dfa58e5b03b18e23fd5fefa21a98fbf7fcfacf16 100644 (file)
@@ -27,6 +27,7 @@
 #include "box3d.h"
 #include "camera-scene-node.h"
 #include "device.h"
+#include "gsubr.h"
 #include "keymap.h"
 #include "material.h"
 #include "mesh.h"
@@ -43,34 +44,18 @@ extern "C" {
   init_scene_manager (void)
   {
     init_scene_manager_type ();
-    scm_c_define_gsubr ("add-animated-mesh-scene-node!", 2, 0, 1,
-                        (scm_t_subr)irr_scene_addAnimatedMeshSceneNode);
-    scm_c_define_gsubr ("add-camera-scene-node!", 1, 0, 1,
-                        (scm_t_subr)irr_scene_addCameraSceneNode);
-    scm_c_define_gsubr ("add-camera-scene-node-fps!", 1, 0, 1,
-                        (scm_t_subr)irr_scene_addCameraSceneNodeFPS);
-    scm_c_define_gsubr ("add-cube-scene-node!", 1, 0, 1,
-                        (scm_t_subr)irr_scene_addCubeSceneNode);
-    scm_c_define_gsubr ("add-custom-scene-node!", 5, 0, 1,
-                        (scm_t_subr)irr_scene_addCustomSceneNode);
-    scm_c_define_gsubr ("add-octree-scene-node!", 2, 0, 1,
-                        (scm_t_subr)irr_scene_addOctreeSceneNode);
-    scm_c_define_gsubr ("add-sphere-scene-node!", 1, 0, 1,
-                        (scm_t_subr)irr_scene_addSphereSceneNode);
-    scm_c_define_gsubr ("create-fly-circle-animator", 1, 0, 1,
-                        (scm_t_subr)irr_scene_createFlyCircleAnimator);
-    scm_c_define_gsubr ("create-fly-straight-animator", 4, 0, 1,
-                        (scm_t_subr)irr_scene_createFlyStraightAnimator);
-    scm_c_define_gsubr ("create-rotation-animator", 2, 0, 0,
-                        (scm_t_subr)irr_scene_createRotationAnimator);
-    scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh);
-    scm_c_define_gsubr ("get-root-scene-node", 1, 0, 0, (scm_t_subr)irr_scene_getRootSceneNode);
-    scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager);
-    scm_c_export ("add-animated-mesh-scene-node!", "add-camera-scene-node!",
-                  "add-camera-scene-node-fps!", "add-custom-scene-node!", "add-cube-scene-node!",
-                  "add-octree-scene-node!", "add-sphere-scene-node!", "create-fly-circle-animator",
-                  "create-fly-straight-animator", "create-rotation-animator", "get-mesh",
-                  "get-root-scene-node", "get-scene-manager", NULL);
+    DEFINE_GSUBR ("add-animated-mesh-scene-node!", 2, 0, 1, irr_scene_addAnimatedMeshSceneNode);
+    DEFINE_GSUBR ("add-camera-scene-node!", 1, 0, 1, irr_scene_addCameraSceneNode);
+    DEFINE_GSUBR ("add-camera-scene-node-fps!", 1, 0, 1, irr_scene_addCameraSceneNodeFPS);
+    DEFINE_GSUBR ("add-cube-scene-node!", 1, 0, 1, irr_scene_addCubeSceneNode);
+    DEFINE_GSUBR ("add-custom-scene-node!", 5, 0, 1, irr_scene_addCustomSceneNode);
+    DEFINE_GSUBR ("add-octree-scene-node!", 2, 0, 1, irr_scene_addOctreeSceneNode);
+    DEFINE_GSUBR ("add-sphere-scene-node!", 1, 0, 1, irr_scene_addSphereSceneNode);
+    DEFINE_GSUBR ("create-fly-circle-animator", 1, 0, 1, irr_scene_createFlyCircleAnimator);
+    DEFINE_GSUBR ("create-fly-straight-animator", 4, 0, 1, irr_scene_createFlyStraightAnimator);
+    DEFINE_GSUBR ("create-rotation-animator", 2, 0, 0, irr_scene_createRotationAnimator);
+    DEFINE_GSUBR ("get-mesh", 2, 0, 0, irr_scene_getMesh);
+    DEFINE_GSUBR ("get-root-scene-node", 1, 0, 0, irr_scene_getRootSceneNode);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
@@ -82,7 +67,7 @@ extern "C" {
                                       SCM mesh,
                                       SCM rest)
   {
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM id = scm_from_int32 (-1);
     SCM position = scm_list_3 (scm_from_double (0),
                                scm_from_double (0),
@@ -93,7 +78,7 @@ extern "C" {
     SCM scale = scm_list_3 (scm_from_double (1),
                             scm_from_double (1),
                             scm_from_double (1));
-    SCM also_add_if_mesh_pointer_zero = scm_from_bool (0);
+    SCM also_add_if_mesh_pointer_zero = SCM_BOOL_F;
 
     scm_c_bind_keyword_arguments ("add-animated-mesh-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
                                   scm_from_utf8_keyword ("parent"), &parent,
@@ -107,7 +92,7 @@ extern "C" {
     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
     irr::scene::IAnimatedMeshSceneNode* node =
       smgr->addAnimatedMeshSceneNode (unwrap_animated_mesh (mesh),
-                                      scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+                                      parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                       scm_to_int32 (id),
                                       scm_to_vector3df (position),
                                       scm_to_vector3df (rotation),
@@ -120,7 +105,7 @@ extern "C" {
   irr_scene_addCameraSceneNode (SCM wrapped_scene_manager,
                                 SCM rest)
   {
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM position = scm_list_3 (scm_from_double (0),
                                scm_from_double (0),
                                scm_from_double (0));
@@ -128,7 +113,7 @@ extern "C" {
                              scm_from_double (0),
                              scm_from_double (100));
     SCM id = scm_from_int32 (-1);
-    SCM make_active = scm_from_bool (1);
+    SCM make_active = SCM_BOOL_T;
 
     scm_c_bind_keyword_arguments ("add-camera-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
                                   scm_from_utf8_keyword ("parent"), &parent,
@@ -140,7 +125,7 @@ extern "C" {
 
     irr::scene::ISceneManager* scene_manager = unwrap_scene_manager (wrapped_scene_manager);
     irr::scene::ICameraSceneNode* camera =
-      scene_manager->addCameraSceneNode (scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+      scene_manager->addCameraSceneNode (parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                          scm_to_vector3df (position),
                                          scm_to_vector3df (lookat),
                                          scm_to_int32 (id),
@@ -152,16 +137,16 @@ extern "C" {
   irr_scene_addCameraSceneNodeFPS (SCM wrapped_scene_manager,
                                    SCM rest)
   {
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM rotate_speed = scm_from_double (100);
     SCM move_speed = scm_from_double (0.5);
     SCM id = scm_from_int32 (-1);
-    SCM key_map_array = scm_from_bool (0);
+    SCM key_map_array = SCM_UNDEFINED;
     SCM key_map_size = scm_from_int32 (0);
-    SCM no_vertical_movement = scm_from_bool (0);
+    SCM no_vertical_movement = SCM_BOOL_F;
     SCM jump_speed = scm_from_double (0);
-    SCM invert_mouse = scm_from_bool (0);
-    SCM make_active = scm_from_bool (1);
+    SCM invert_mouse = SCM_BOOL_F;
+    SCM make_active = SCM_BOOL_T;
     
     scm_c_bind_keyword_arguments ("add-camera-scene-node-fps!", rest, (scm_t_keyword_arguments_flags)0,
                                   scm_from_utf8_keyword ("parent"), &parent,
@@ -178,11 +163,11 @@ extern "C" {
 
     irr::scene::ISceneManager* scene_manager = unwrap_scene_manager (wrapped_scene_manager);
     irr::scene::ICameraSceneNode* camera =
-      scene_manager->addCameraSceneNodeFPS (scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+      scene_manager->addCameraSceneNodeFPS (parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                             scm_to_double (rotate_speed),
                                             scm_to_double (move_speed),
                                             scm_to_int32 (id),
-                                            scm_is_false (key_map_array) ? 0 : unwrap_keymap (key_map_array),
+                                            key_map_array == SCM_UNDEFINED ? 0 : unwrap_keymap (key_map_array),
                                             scm_to_int32 (key_map_size),
                                             scm_to_bool (no_vertical_movement),
                                             scm_to_double (jump_speed),
@@ -196,7 +181,7 @@ extern "C" {
                               SCM rest)
   {
     SCM size = scm_from_double (10);
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM id = scm_from_int32 (-1);
     SCM position = scm_list_3 (scm_from_double (0),
                                scm_from_double (0),
@@ -220,7 +205,7 @@ extern "C" {
     irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
     irr::scene::IMeshSceneNode* node =
       smgr->addCubeSceneNode (scm_to_double (size),
-                              scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+                              parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                               scm_to_int32 (id),
                               scm_to_vector3df (position),
                               scm_to_vector3df (rotation),
@@ -335,10 +320,10 @@ extern "C" {
                                 SCM wrapped_mesh,
                                 SCM rest)
   {
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM id = scm_from_int32 (-1);
     SCM minimal_polys_per_node = scm_from_int32 (256);
-    SCM also_add_if_mesh_pointer_zero = scm_from_bool (0);
+    SCM also_add_if_mesh_pointer_zero = SCM_BOOL_F;
 
     scm_c_bind_keyword_arguments ("add-octree-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
                                   scm_from_utf8_keyword ("parent"), &parent,
@@ -352,7 +337,7 @@ extern "C" {
     if (animated_mesh_p (wrapped_mesh))
       {
         node = smgr->addOctreeSceneNode (unwrap_animated_mesh (wrapped_mesh),
-                                         scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+                                         parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                          scm_to_int32 (id),
                                          scm_to_int32 (minimal_polys_per_node),
                                          scm_to_bool (also_add_if_mesh_pointer_zero));
@@ -360,7 +345,7 @@ extern "C" {
     else
       {
         node = smgr->addOctreeSceneNode (unwrap_mesh (wrapped_mesh),
-                                         scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+                                         parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                          scm_to_int32 (id),
                                          scm_to_int32 (minimal_polys_per_node),
                                          scm_to_bool (also_add_if_mesh_pointer_zero));
@@ -374,7 +359,7 @@ extern "C" {
   {
     SCM radius = scm_from_double (5.0);
     SCM poly_count = scm_from_int32 (16);
-    SCM parent = scm_from_bool (0);
+    SCM parent = SCM_UNDEFINED;
     SCM id = scm_from_int32 (-1);
     SCM position = scm_list_3 (scm_from_double (0),
                                scm_from_double (0),
@@ -400,7 +385,7 @@ extern "C" {
     irr::scene::IMeshSceneNode* node =
       smgr->addSphereSceneNode (scm_to_double (radius),
                                 scm_to_int32 (poly_count),
-                                scm_is_false (parent) ? 0 : unwrap_scene_node (parent),
+                                parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
                                 scm_to_int32 (id),
                                 scm_to_vector3df (position),
                                 scm_to_vector3df (rotation),
@@ -450,8 +435,8 @@ extern "C" {
                                        SCM time_for_way,
                                        SCM rest)
   {
-    SCM loop = scm_from_bool (0);
-    SCM pingpong = scm_from_bool (0);
+    SCM loop = SCM_BOOL_F;
+    SCM pingpong = SCM_BOOL_F;
 
     scm_c_bind_keyword_arguments ("create-fly-straight-animator", rest, (scm_t_keyword_arguments_flags)0,
                                   scm_from_utf8_keyword ("loop"), &loop,
@@ -494,20 +479,4 @@ extern "C" {
     return wrap_scene_node (smgr->getRootSceneNode ());
   }
 
-  SCM
-  irr_getSceneManager (SCM wrapped_obj)
-  {
-    irr::scene::ISceneManager* scene_manager;
-    if (device_p (wrapped_obj))
-      {
-        scene_manager = unwrap_device (wrapped_obj)->getSceneManager ();
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Cannot get scene manager from object: ~S",
-                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
-      }
-    return wrap_scene_manager (scene_manager);
-  }
-
 }