]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
add-camera-scene-node-fps!
authorJavier Sancho <jsf@jsancho.org>
Sat, 21 Mar 2020 18:24:31 +0000 (19:24 +0100)
committerJavier Sancho <jsf@jsancho.org>
Sat, 21 Mar 2020 18:24:31 +0000 (19:24 +0100)
Makefile.am
src/guile-irrlicht.cpp
src/keymap.cpp [new file with mode: 0644]
src/keymap.h [new file with mode: 0644]
src/scene-manager.cpp
src/scene-manager.h

index 474823b1db0fc561c805fb8b7f9fb15774e7e806..f447eb8738b3e5f67d4c8e64f2a8ef1f224c1baf 100644 (file)
@@ -38,6 +38,7 @@ libguile_irrlicht_la_SOURCES = \
   src/gui-environment.cpp \
   src/gui-static-text.cpp \
   src/guile-irrlicht.cpp \
+  src/keymap.cpp \
   src/material-flags.cpp \
   src/mesh.cpp \
   src/mesh-scene-node.cpp \
index dad52c2c1cada3518db70101d080bd98dfa15533..69215ac115232b22bb141f37a4015a0c219be348 100644 (file)
@@ -31,6 +31,7 @@
 #include "gui-element.h"
 #include "gui-environment.h"
 #include "gui-static-text.h"
+#include "keymap.h"
 #include "material-flags.h"
 #include "mesh.h"
 #include "mesh-scene-node.h"
@@ -56,6 +57,7 @@ extern "C" {
     init_gui_element ();
     init_gui_environment ();
     init_gui_static_text ();
+    init_keymap ();
     init_material_flag ();
     init_mesh ();
     init_mesh_scene_node ();
diff --git a/src/keymap.cpp b/src/keymap.cpp
new file mode 100644 (file)
index 0000000..ba2e94e
--- /dev/null
@@ -0,0 +1,39 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "keymap.h"
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_keymap (void)
+  {
+    init_keymap_type ();
+  }
+
+  DEFINE_WRAPPED_TYPE (irr::SKeyMap*, "keymap",
+                       init_keymap_type, keymap_p,
+                       wrap_keymap, unwrap_keymap);
+
+}
diff --git a/src/keymap.h b/src/keymap.h
new file mode 100644 (file)
index 0000000..83d2844
--- /dev/null
@@ -0,0 +1,39 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __GUILE_IRRLICHT_KEYMAP_H_INCLUDED__
+#define __GUILE_IRRLICHT_KEYMAP_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_keymap (void);
+
+  DECLARE_WRAPPED_TYPE (irr::SKeyMap*, init_keymap_type,
+                        keymap_p, wrap_keymap, unwrap_keymap);
+
+}
+
+#endif
index 0f3e54cdae86130a56d8675dbc4364ca971ec9a9..eb7a3780ab6361e2afd0c72fcf3d70ed3041b7ab 100644 (file)
@@ -26,6 +26,7 @@
 #include "animated-mesh-scene-node.h"
 #include "camera-scene-node.h"
 #include "device.h"
+#include "keymap.h"
 #include "mesh.h"
 #include "mesh-scene-node.h"
 #include "scene-manager.h"
@@ -43,12 +44,15 @@ extern "C" {
                         (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-octree-scene-node!", 2, 0, 1,
                         (scm_t_subr)irr_scene_addOctreeSceneNode);
     scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh);
     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-octree-scene-node!", "get-mesh", "get-scene-manager", NULL);
+                  "add-camera-scene-node-fps!", "add-octree-scene-node!",
+                  "get-mesh", "get-scene-manager", NULL);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
@@ -126,6 +130,49 @@ extern "C" {
     return wrap_camera_scene_node (camera);
   }
 
+  SCM
+  irr_scene_addCameraSceneNodeFPS (SCM wrapped_scene_manager,
+                                   SCM rest)
+  {
+    SCM parent = scm_from_bool (0);
+    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_size = scm_from_int32 (0);
+    SCM no_vertical_movement = scm_from_bool (0);
+    SCM jump_speed = scm_from_double (0);
+    SCM invert_mouse = scm_from_bool (0);
+    SCM make_active = scm_from_bool (1);
+    
+    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 (scm_is_false (parent) ? 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),
+                                            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_addOctreeSceneNode (SCM wrapped_scene_manager,
                                 SCM wrapped_mesh,
index 39f020d603aba955c80b102828f7e3688b68360e..41af5579fd2cc14119e77f077997d473d6a4a2ee 100644 (file)
@@ -43,6 +43,10 @@ extern "C" {
   irr_scene_addCameraSceneNode (SCM wrapped_scene_manager,
                                 SCM rest);
 
+  SCM
+  irr_scene_addCameraSceneNodeFPS (SCM wrapped_scene_manager,
+                                   SCM rest);
+
   SCM
   irr_scene_addOctreeSceneNode (SCM wrapped_scene_manager,
                                 SCM wrapped_mesh,