]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
scene-manager
authorJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 09:40:56 +0000 (11:40 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 09:40:56 +0000 (11:40 +0200)
src/scene-manager.cpp
src/scene-manager.h

index af96eebc403b09188d10ce0adbe863a9da2aa638..d5b9e6cf18f529b0b58dd3c1cefcabd58aa9871c 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
-#include "animated-mesh.h"
-#include "animated-mesh-scene-node.h"
-#include "box3d.h"
-#include "camera-scene-node.h"
-#include "device.h"
 #include "gsubr.h"
-#include "keymap.h"
-#include "material.h"
-#include "mesh.h"
-#include "mesh-scene-node.h"
 #include "scene-manager.h"
-#include "scene-node.h"
-#include "scene-node-animator.h"
 #include "vector3d.h"
-#include "wrapped.h"
 
-  SCM
-  irr_drawAll (SCM wrapped_obj)
-  {
-    if (gui_environment_p (wrapped_obj))
-      {
-        unwrap_gui_environment (wrapped_obj)->drawAll ();
-      }
-    else if (scene_manager_p (wrapped_obj))
-      {
-        unwrap_scene_manager (wrapped_obj)->drawAll ();
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S",
-                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
-      }
-    return SCM_UNSPECIFIED;
-  }
 
-extern "C" {
+using namespace irr;
+
+
+template <typename TParent>
+SCM
+scene_ISceneManager_addAnimatedMeshSceneNode (SCM scene_manager,
+                                              SCM mesh,
+                                              SCM parent,
+                                              SCM id,
+                                              SCM position,
+                                              SCM rotation,
+                                              SCM scale,
+                                              SCM also_add_if_mesh_pointer_zero)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::IAnimatedMeshSceneNode* node =
+    smgr->addAnimatedMeshSceneNode ((scene::IAnimatedMesh*) scm_to_pointer (mesh),
+                                    (TParent) scm_to_pointer (parent),
+                                    scm_to_int32 (id),
+                                    scm_to_vector3df (position),
+                                    scm_to_vector3df (rotation),
+                                    scm_to_vector3df (scale),
+                                    scm_to_bool (also_add_if_mesh_pointer_zero));
+  return scm_from_pointer ((void*) node, NULL);
+}
 
-  void
-  init_scene_manager (void)
-  {
-    init_scene_manager_type ();
-    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",
-                       init_scene_manager_type, scene_manager_p,
-                       wrap_scene_manager, unwrap_scene_manager);
+template <typename TParent>
+SCM
+scene_ISceneManager_addCameraSceneNode (SCM scene_manager,
+                                        SCM parent,
+                                        SCM position,
+                                        SCM lookat,
+                                        SCM id,
+                                        SCM make_active)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::ICameraSceneNode* camera =
+    smgr->addCameraSceneNode ((TParent) scm_to_pointer (parent),
+                              scm_to_vector3df (position),
+                              scm_to_vector3df (lookat),
+                              scm_to_int32 (id),
+                              scm_to_bool (make_active));
+  return scm_from_pointer ((void*) camera, NULL);
+}
 
-  SCM
-  irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
-                                      SCM mesh,
-                                      SCM rest)
-  {
-    SCM parent = SCM_UNDEFINED;
-    SCM id = scm_from_int32 (-1);
-    SCM position = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM rotation = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    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_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,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("position"), &position,
-                                  scm_from_utf8_keyword ("rotation"), &rotation,
-                                  scm_from_utf8_keyword ("scale"), &scale,
-                                  scm_from_utf8_keyword ("also-add-if-mesh-pointer-zero"), &also_add_if_mesh_pointer_zero,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::IAnimatedMeshSceneNode* node =
-      smgr->addAnimatedMeshSceneNode (unwrap_animated_mesh (mesh),
-                                      parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
-                                      scm_to_int32 (id),
-                                      scm_to_vector3df (position),
-                                      scm_to_vector3df (rotation),
-                                      scm_to_vector3df (scale),
-                                      scm_to_bool (also_add_if_mesh_pointer_zero));
-    return wrap_animated_mesh_scene_node (node);
-  }
 
-  SCM
-  irr_scene_addCameraSceneNode (SCM wrapped_scene_manager,
-                                SCM rest)
-  {
-    SCM parent = SCM_UNDEFINED;
-    SCM position = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM lookat = scm_list_3 (scm_from_double (0),
-                             scm_from_double (0),
-                             scm_from_double (100));
-    SCM id = scm_from_int32 (-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,
-                                  scm_from_utf8_keyword ("position"), &position,
-                                  scm_from_utf8_keyword ("lookat"), &lookat,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("make-active"), &make_active,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* scene_manager = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::ICameraSceneNode* camera =
-      scene_manager->addCameraSceneNode (parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
-                                         scm_to_vector3df (position),
-                                         scm_to_vector3df (lookat),
-                                         scm_to_int32 (id),
-                                         scm_to_bool (make_active));
-    return wrap_camera_scene_node (camera);
-  }
+template <typename TParent>
+SCM
+scene_ISceneManager_addCameraSceneNodeFPS (SCM scene_manager,
+                                           SCM parent,
+                                           SCM rotate_speed,
+                                           SCM move_speed,
+                                           SCM id,
+                                           SCM key_map_array,
+                                           SCM key_map_size,
+                                           SCM no_vertical_movement,
+                                           SCM jump_speed,
+                                           SCM invert_mouse,
+                                           SCM make_active)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::ICameraSceneNode* camera =
+    smgr->addCameraSceneNodeFPS ((TParent) scm_to_pointer (parent),
+                                 scm_to_double (rotate_speed),
+                                 scm_to_double (move_speed),
+                                 scm_to_int32 (id),
+                                 (SKeyMap*) scm_to_pointer (key_map_array),
+                                 scm_to_int32 (key_map_size),
+                                 scm_to_bool (no_vertical_movement),
+                                 scm_to_double (jump_speed),
+                                 scm_to_bool (invert_mouse),
+                                 scm_to_bool (make_active));
+  return scm_from_pointer ((void*) camera, NULL);
+}
 
-  SCM
-  irr_scene_addCameraSceneNodeFPS (SCM wrapped_scene_manager,
-                                   SCM rest)
-  {
-    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_UNDEFINED;
-    SCM key_map_size = scm_from_int32 (0);
-    SCM no_vertical_movement = SCM_BOOL_F;
-    SCM jump_speed = scm_from_double (0);
-    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,
-                                  scm_from_utf8_keyword ("rotate-speed"), &rotate_speed,
-                                  scm_from_utf8_keyword ("move-speed"), &move_speed,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("key-map-array"), &key_map_array,
-                                  scm_from_utf8_keyword ("key-map-size"), &key_map_size,
-                                  scm_from_utf8_keyword ("no-vertical-movement"), &no_vertical_movement,
-                                  scm_from_utf8_keyword ("jump-speed"), &jump_speed,
-                                  scm_from_utf8_keyword ("invert-mouse"), &invert_mouse,
-                                  scm_from_utf8_keyword ("make-active"), &make_active,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* scene_manager = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::ICameraSceneNode* camera =
-      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),
-                                            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),
-                                            scm_to_bool (invert_mouse),
-                                            scm_to_bool (make_active));
-    return wrap_camera_scene_node (camera);
-  }
 
-  SCM
-  irr_scene_addCubeSceneNode (SCM wrapped_scene_manager,
-                              SCM rest)
+template <typename TParent>
+SCM
+scene_ISceneManager_addCubeSceneNode (SCM scene_manager,
+                                      SCM size,
+                                      SCM parent,
+                                      SCM id,
+                                      SCM position,
+                                      SCM rotation,
+                                      SCM scale)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::IMeshSceneNode* node =
+    smgr->addCubeSceneNode (scm_to_double (size),
+                            (TParent) scm_to_pointer (parent),
+                            scm_to_int32 (id),
+                            scm_to_vector3df (position),
+                            scm_to_vector3df (rotation),
+                            scm_to_vector3df (scale));
+  return scm_from_pointer ((void*) camera, NULL);
+}
+
+
+template <typename TParent>
+SCM
+scene_ISceneManager_addCustomSceneNode (SCM scene_manager,
+                                        SCM proc_render,
+                                        SCM proc_get_bounding_box,
+                                        SCM proc_get_material_count,
+                                        SCM proc_get_material,
+                                        SCM parent,
+                                        SCM id,
+                                        SCM position,
+                                        SCM rotation,
+                                        SCM scale)
+{
+  class CustomSceneNode : public scene::ISceneNode
   {
-    SCM size = scm_from_double (10);
-    SCM parent = SCM_UNDEFINED;
-    SCM id = scm_from_int32 (-1);
-    SCM position = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM rotation = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM scale = scm_list_3 (scm_from_double (1),
-                            scm_from_double (1),
-                            scm_from_double (1));
-
-    scm_c_bind_keyword_arguments ("add-cube-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("size"), &size,
-                                  scm_from_utf8_keyword ("parent"), &parent,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("position"), &position,
-                                  scm_from_utf8_keyword ("rotation"), &rotation,
-                                  scm_from_utf8_keyword ("scale"), &scale,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::IMeshSceneNode* node =
-      smgr->addCubeSceneNode (scm_to_double (size),
-                              parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
+    SCM scm_render;
+    SCM scm_get_bounding_box;
+    SCM scm_get_material_count;
+    SCM scm_get_material;
+
+  public:
+    CustomSceneNode (scene::ISceneNode* parent,
+                     scene::ISceneManager* smgr,
+                     s32 id,
+                     const core::vector3df& position,
+                     const core::vector3df& rotation,
+                     const core::vector3df& scale,
+                     SCM render,
+                     SCM get_bounding_box,
+                     SCM get_material_count,
+                     SCM get_material)
+      : scene::ISceneNode (parent, smgr, id, position, rotation, scale)
+    {
+      scm_render = render;
+      scm_get_bounding_box = get_bounding_box;
+      scm_get_material_count = get_material_count;
+      scm_get_material = get_material;
+    }
+
+    virtual void OnRegisterSceneNode ()
+    {
+      if (IsVisible)
+        {
+          SceneManager->registerNodeForRendering (this);
+        }
+      ISceneNode::OnRegisterSceneNode ();
+    }
+
+    virtual void render ()
+    {
+      scm_call_0 (scm_render);
+    }
+
+    virtual const core::aabbox3d<f32>& getBoundingBox () const
+    {
+      SCM box = scm_call_0 (scm_get_bounding_box);
+      return *((core::aabbox3d<f32>*) scm_to_pointer (box));
+    }
+
+    virtual u32 getMaterialCount () const
+    {
+      return scm_to_uint32 (scm_call_0 (scm_get_material_count));
+    }
+
+    virtual video::SMaterial& getMaterial (u32 i)
+    {
+      SCM material = scm_call_1 (scm_get_material, scm_from_uint32 (i));
+      return *((video::SMaterial*) scm_to_pointer (material));
+    }
+  };
+
+  CustomSceneNode* node =
+    new CustomSceneNode ((TParent) scm_to_pointer (parent),
+                         (scene::ISceneManager*) scm_to_pointer (scene_manager),
+                         scm_to_int32 (id),
+                         scm_to_vector3df (position),
+                         scm_to_vector3df (rotation),
+                         scm_to_vector3df (scale),
+                         proc_render,
+                         proc_get_bounding_box,
+                         proc_get_material_count,
+                         proc_get_material);
+  return scm_from_pointer ((void*) node, NULL);
+}
+
+
+template <typename TParent, typename TMesh>
+SCM
+scene_ISceneManager_addOctreeSceneNode (SCM scene_manager,
+                                        SCM mesh,
+                                        SCM parent,
+                                        SCM id,
+                                        SCM minimal_polys_per_node,
+                                        SCM also_add_if_mesh_pointer_zero)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::IMeshSceneNode* node =
+    smgr->addOctreeSceneNode ((TMesh) scm_to_pointer (mesh),
+                              (TParent) scm_to_pointer (parent),
+                              scm_to_int32 (id),
+                              scm_to_int32 (minimal_polys_per_node),
+                              scm_to_bool (also_add_if_mesh_pointer_zero));
+  return scm_from_pointer ((void*) node, NULL);
+}
+
+
+template <typename TParent>
+SCM
+scene_ISceneManager_addSphereSceneNode (SCM scene_manager,
+                                        SCM radius,
+                                        SCM poly_count,
+                                        SCM parent,
+                                        SCM id,
+                                        SCM position,
+                                        SCM rotation,
+                                        SCM scale)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::IMeshSceneNode* node =
+    smgr->addSphereSceneNode (scm_to_double (radius),
+                              scm_to_int32 (poly_count),
+                              (TParent) scm_to_pointer (parent),
                               scm_to_int32 (id),
                               scm_to_vector3df (position),
                               scm_to_vector3df (rotation),
                               scm_to_vector3df (scale));
-    return wrap_mesh_scene_node (node);
-  }
+  return scm_from_pointer ((void*) node, NULL);
+}
 
-  SCM
-  irr_scene_addCustomSceneNode (SCM wrapped_scene_manager,
-                                SCM proc_render,
-                                SCM proc_get_bounding_box,
-                                SCM proc_get_material_count,
-                                SCM proc_get_material,
-                                SCM rest)
-  {
-    irr::scene::ISceneManager* scene_manager = unwrap_scene_manager (wrapped_scene_manager);
-
-    SCM parent = wrap_scene_node (scene_manager->getRootSceneNode ());
-    SCM id = scm_from_int32 (-1);
-    SCM position = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM rotation = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM scale = scm_list_3 (scm_from_double (1),
-                            scm_from_double (1),
-                            scm_from_double (1));
-
-    scm_c_bind_keyword_arguments ("add-custom-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("parent"), &parent,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("position"), &position,
-                                  scm_from_utf8_keyword ("rotation"), &rotation,
-                                  scm_from_utf8_keyword ("scale"), &scale,
-                                  SCM_UNDEFINED);
-
-    class CustomSceneNode : public irr::scene::ISceneNode
-    {
-      SCM scm_render;
-      SCM scm_get_bounding_box;
-      SCM scm_get_material_count;
-      SCM scm_get_material;
-
-    public:
-      CustomSceneNode (irr::scene::ISceneNode* parent,
-                       irr::scene::ISceneManager* smgr,
-                       irr::s32 id,
-                       const irr::core::vector3df& position,
-                       const irr::core::vector3df& rotation,
-                       const irr::core::vector3df& scale,
-                       SCM render,
-                       SCM get_bounding_box,
-                       SCM get_material_count,
-                       SCM get_material)
-        : irr::scene::ISceneNode (parent, smgr, id, position, rotation, scale)
-      {
-        scm_render = render;
-        scm_get_bounding_box = get_bounding_box;
-        scm_get_material_count = get_material_count;
-        scm_get_material = get_material;
-      }
-
-      virtual void OnRegisterSceneNode ()
-      {
-        if (IsVisible)
-          {
-            SceneManager->registerNodeForRendering (this);
-          }
-        ISceneNode::OnRegisterSceneNode ();
-      }
-
-      virtual void render ()
-      {
-        scm_call_0 (scm_render);
-      }
-
-      virtual const irr::core::aabbox3d<irr::f32>& getBoundingBox () const
-      {
-        SCM box = scm_call_0 (scm_get_bounding_box);
-        return *(unwrap_box3d (box));
-      }
-
-      virtual irr::u32 getMaterialCount () const
-      {
-        return scm_to_uint32 (scm_call_0 (scm_get_material_count));
-      }
-
-      virtual irr::video::SMaterial& getMaterial (irr::u32 i)
-      {
-        SCM material = scm_call_1 (scm_get_material, scm_from_uint32 (i));
-        return *(unwrap_material (material));
-      }
-    };
-
-    CustomSceneNode* node =
-      new CustomSceneNode (unwrap_scene_node (parent),
-                           scene_manager,
-                           scm_to_int32 (id),
-                           scm_to_vector3df (position),
-                           scm_to_vector3df (rotation),
-                           scm_to_vector3df (scale),
-                           proc_render,
-                           proc_get_bounding_box,
-                           proc_get_material_count,
-                           proc_get_material);
-    return wrap_scene_node (node);
-  }
 
-  SCM
-  irr_scene_addOctreeSceneNode (SCM wrapped_scene_manager,
-                                SCM wrapped_mesh,
-                                SCM rest)
-  {
-    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_BOOL_F;
-
-    scm_c_bind_keyword_arguments ("add-octree-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("parent"), &parent,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("minimal-polys-per-node"), &minimal_polys_per_node,
-                                  scm_from_utf8_keyword ("also-add-if-mesh-pointer-zero"), &also_add_if_mesh_pointer_zero,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::IMeshSceneNode* node;
-    if (animated_mesh_p (wrapped_mesh))
-      {
-        node = smgr->addOctreeSceneNode (unwrap_animated_mesh (wrapped_mesh),
-                                         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));
-      }
-    else
-      {
-        node = smgr->addOctreeSceneNode (unwrap_mesh (wrapped_mesh),
-                                         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));
-      }
-    return wrap_mesh_scene_node (node);
-  }
+SCM
+scene_ISceneManager_createFlyCircleAnimator (SCM scene_manager,
+                                             SCM center,
+                                             SCM radius,
+                                             SCM speed,
+                                             SCM direction,
+                                             SCM start_position,
+                                             SCM radius_ellipsoid)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::ISceneNodeAnimator* anim =
+    smgr->createFlyCircleAnimator (scm_to_vector3df (center),
+                                   scm_to_double (radius),
+                                   scm_to_double (speed),
+                                   scm_to_vector3df (direction),
+                                   scm_to_double (start_position),
+                                   scm_to_double (radius_ellipsoid));
+  return scm_from_pointer ((void*) anim, NULL);
+}
 
-  SCM
-  irr_scene_addSphereSceneNode (SCM wrapped_scene_manager,
-                                SCM rest)
-  {
-    SCM radius = scm_from_double (5.0);
-    SCM poly_count = scm_from_int32 (16);
-    SCM parent = SCM_UNDEFINED;
-    SCM id = scm_from_int32 (-1);
-    SCM position = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM rotation = scm_list_3 (scm_from_double (0),
-                               scm_from_double (0),
-                               scm_from_double (0));
-    SCM scale = scm_list_3 (scm_from_double (1),
-                            scm_from_double (1),
-                            scm_from_double (1));
-
-    scm_c_bind_keyword_arguments ("add-sphere-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("radius"), &radius,
-                                  scm_from_utf8_keyword ("poly-count"), &poly_count,
-                                  scm_from_utf8_keyword ("parent"), &parent,
-                                  scm_from_utf8_keyword ("id"), &id,
-                                  scm_from_utf8_keyword ("position"), &position,
-                                  scm_from_utf8_keyword ("rotation"), &rotation,
-                                  scm_from_utf8_keyword ("scale"), &scale,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::IMeshSceneNode* node =
-      smgr->addSphereSceneNode (scm_to_double (radius),
-                                scm_to_int32 (poly_count),
-                                parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
-                                scm_to_int32 (id),
-                                scm_to_vector3df (position),
-                                scm_to_vector3df (rotation),
-                                scm_to_vector3df (scale));
-    return wrap_mesh_scene_node (node);
-  }
 
-  SCM
-  irr_scene_createFlyCircleAnimator (SCM wrapped_scene_manager,
-                                     SCM rest)
-  {
-    SCM center = scm_list_3 (scm_from_double (0),
-                             scm_from_double (0),
-                             scm_from_double (0));
-    SCM radius = scm_from_double (100);
-    SCM speed = scm_from_double (0.001);
-    SCM direction = scm_list_3 (scm_from_double (0),
-                                scm_from_double (1),
-                                scm_from_double (0));
-    SCM start_position = scm_from_double (0);
-    SCM radius_ellipsoid = scm_from_double (0);
-
-    scm_c_bind_keyword_arguments ("create-fly-circle-animator", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("center"), &center,
-                                  scm_from_utf8_keyword ("radius"), &radius,
-                                  scm_from_utf8_keyword ("speed"), &speed,
-                                  scm_from_utf8_keyword ("direction"), &direction,
-                                  scm_from_utf8_keyword ("start-position"), &start_position,
-                                  scm_from_utf8_keyword ("radius-ellipsoid"), &radius_ellipsoid,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::ISceneNodeAnimator* anim =
-      smgr->createFlyCircleAnimator (scm_to_vector3df (center),
-                                     scm_to_double (radius),
-                                     scm_to_double (speed),
-                                     scm_to_vector3df (direction),
-                                     scm_to_double (start_position),
-                                     scm_to_double (radius_ellipsoid));
-    return wrap_scene_node_animator (anim);
-  }
+SCM
+scene_ISceneManager_createFlyStraightAnimator (SCM scene_manager,
+                                               SCM start_point,
+                                               SCM end_point,
+                                               SCM time_for_way,
+                                               SCM loop,
+                                               SCM pingpong)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::ISceneNodeAnimator* anim =
+    smgr->createFlyStraightAnimator (scm_to_vector3df (start_point),
+                                     scm_to_vector3df (end_point),
+                                     scm_to_uint32 (time_for_way),
+                                     scm_to_bool (loop),
+                                     scm_to_bool (pingpong));
+  return scm_from_pointer ((void*) anim, NULL);
+}
 
-  SCM
-  irr_scene_createFlyStraightAnimator (SCM wrapped_scene_manager,
-                                       SCM start_point,
-                                       SCM end_point,
-                                       SCM time_for_way,
-                                       SCM rest)
-  {
-    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,
-                                  scm_from_utf8_keyword ("pingpong"), &pingpong,
-                                  SCM_UNDEFINED);
-
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::ISceneNodeAnimator* anim =
-      smgr->createFlyStraightAnimator (scm_to_vector3df (start_point),
-                                       scm_to_vector3df (end_point),
-                                       scm_to_uint32 (time_for_way),
-                                       scm_to_bool (loop),
-                                       scm_to_bool (pingpong));
-    return wrap_scene_node_animator (anim);
-  }
 
-  SCM
-  irr_scene_createRotationAnimator (SCM wrapped_scene_manager,
-                                    SCM rotation_speed)
-  {
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::ISceneNodeAnimator* anim =
-      smgr->createRotationAnimator (scm_to_vector3df (rotation_speed));
-    return wrap_scene_node_animator (anim);
-  }
+SCM
+scene_ISceneManager_createRotationAnimator (SCM scene_manager,
+                                            SCM rotation_speed)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::ISceneNodeAnimator* anim =
+    smgr->createRotationAnimator (scm_to_vector3df (rotation_speed));
+  return scm_from_pointer ((void*) anim, NULL);
+}
+
+
+SCM
+scene_ISceneManager_drawAll (SCM scene_manager)
+{
+  ((scene::ISceneManager*) scm_to_pointer (scene_manager))->drawAll ();
+  return SCM_UNSPECIFIED;
+}
+
+
+SCM
+scene_ISceneManager_getMesh (SCM scene_manager,
+                             SCM filename)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_stringn (filename, NULL));
+  return scm_from_pointer ((void*) mesh, NULL);
+}
+
+
+SCM
+scene_ISceneManager_getRootSceneNode (SCM scene_manager)
+{
+  scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+  return scm_from_pointer ((void*) smgr->getRootSceneNode (), NULL);
+}
 
-  SCM
-  irr_scene_getMesh (SCM wrapped_scene_manager,
-                     SCM filename)
-  {
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    irr::scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_stringn (filename, NULL));
-    return wrap_animated_mesh (mesh);
-  }
 
-  SCM
-  irr_scene_getRootSceneNode (SCM wrapped_scene_manager)
+extern "C" {
+
+  void
+  init_scene_manager (void)
   {
-    irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
-    return wrap_scene_node (smgr->getRootSceneNode ());
+    DEFINE_GSUBR ("scene_ISceneManager_addAnimatedMeshSceneNode_ISceneNode", 8, 0, 0,
+                  scene_ISceneManager_addAnimatedMeshSceneNode<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addCameraSceneNode_ISceneNode", 6, 0, 0,
+                  scene_ISceneManager_addCameraSceneNode<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addCameraSceneNodeFPS_ISceneNode", 11, 0, 0,
+                  scene_ISceneManager_addCameraSceneNodeFPS<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addCubeSceneNode_ISceneNode", 7, 0, 0,
+                  scene_ISceneManager_addCubeSceneNode<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addCustomSceneNode_ISceneNode", 10, 0, 0,
+                  scene_ISceneManager_addCustomSceneNode<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addOctreeSceneNode_ISceneNode_IAnimatedMesh", 6, 0, 0,
+                  scene_ISceneManager_addOctreeSceneNode<scene::ISceneNode*, scene::IAnimatedMesh*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addOctreeSceneNode_ISceneNode_IMesh", 6, 0, 0,
+                  scene_ISceneManager_addOctreeSceneNode<scene::ISceneNode*, scene::IMesh*>);
+    DEFINE_GSUBR ("scene_ISceneManager_addSphereSceneNode_ISceneNode", 8, 0, 0,
+                  scene_ISceneManager_addSphereSceneNode<scene::ISceneNode*>);
+    DEFINE_GSUBR ("scene_ISceneManager_createFlyCircleAnimator", 7, 0, 0,
+                  scene_ISceneManager_createFlyCircleAnimator);
+    DEFINE_GSUBR ("scene_ISceneManager_createFlyStraightAnimator", 6, 0, 0,
+                  scene_ISceneManager_createFlyStraightAnimator);
+    DEFINE_GSUBR ("scene_ISceneManager_createRotationAnimator", 2, 0, 0,
+                  scene_ISceneManager_createRotationAnimator);
+    DEFINE_GSUBR ("scene_ISceneManager_drawAll", 1, 0, 0, scene_ISceneManager_drawAll);
+    DEFINE_GSUBR ("scene_ISceneManager_getMesh", 2, 0, 0, scene_ISceneManager_getMesh);
+    DEFINE_GSUBR ("scene_ISceneManager_getRootSceneNode", 1, 0, 0,
+                  scene_ISceneManager_getRootSceneNode);
   }
 
 }
index a400e2705743a58ab2a1e967a86b6997519ed239..8722c8f5c21358a33dae231c5ada60be7a568d33 100644 (file)
 #ifndef __GUILE_IRRLICHT_SCENE_MANAGER_H_INCLUDED__
 #define __GUILE_IRRLICHT_SCENE_MANAGER_H_INCLUDED__
 
-#include <irrlicht/irrlicht.h>
-#include <libguile.h>
-#include "wrapped.h"
-
 extern "C" {
-
   void
   init_scene_manager (void);
-
-  DECLARE_WRAPPED_TYPE (irr::scene::ISceneManager*, init_scene_manager_type,
-                        scene_manager_p, wrap_scene_manager, unwrap_scene_manager);
-
-  SCM
-  irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
-                                      SCM mesh,
-                                      SCM rest);
-
-  SCM
-  irr_scene_addCameraSceneNode (SCM wrapped_scene_manager,
-                                SCM rest);
-
-  SCM
-  irr_scene_addCameraSceneNodeFPS (SCM wrapped_scene_manager,
-                                   SCM rest);
-
-  SCM
-  irr_scene_addCubeSceneNode (SCM wrapped_scene_manager,
-                              SCM rest);
-
-  SCM
-  irr_scene_addCustomSceneNode (SCM wrapped_scene_manager,
-                                SCM proc_render,
-                                SCM proc_get_bounding_box,
-                                SCM proc_get_material_count,
-                                SCM proc_get_material,
-                                SCM rest);
-
-  SCM
-  irr_scene_addOctreeSceneNode (SCM wrapped_scene_manager,
-                                SCM wrapped_mesh,
-                                SCM rest);
-
-  SCM
-  irr_scene_addSphereSceneNode (SCM wrapped_scene_manager,
-                                SCM rest);
-
-  SCM
-  irr_scene_createFlyCircleAnimator (SCM wrapped_scene_manager,
-                                     SCM rest);
-
-  SCM
-  irr_scene_createFlyStraightAnimator (SCM wrapped_scene_manager,
-                                       SCM start_point,
-                                       SCM end_point,
-                                       SCM time_for_way,
-                                       SCM rest);
-
-  SCM
-  irr_scene_createRotationAnimator (SCM wrapped_scene_manager,
-                                    SCM rotation_speed);
-
-  SCM
-  irr_scene_getMesh (SCM wrapped_scene_manager,
-                     SCM filename);
-
-  SCM
-  irr_scene_getRootSceneNode (SCM wrapped_scene_manager);
-
 }
 
 #endif