From 3ea56c83d8f0c7994f5113166e315d06aa1dcb4a Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sat, 21 Mar 2020 19:24:31 +0100 Subject: [PATCH] add-camera-scene-node-fps! --- Makefile.am | 1 + src/guile-irrlicht.cpp | 2 ++ src/keymap.cpp | 39 +++++++++++++++++++++++++++++++++ src/keymap.h | 39 +++++++++++++++++++++++++++++++++ src/scene-manager.cpp | 49 +++++++++++++++++++++++++++++++++++++++++- src/scene-manager.h | 4 ++++ 6 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/keymap.cpp create mode 100644 src/keymap.h diff --git a/Makefile.am b/Makefile.am index 474823b..f447eb8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index dad52c2..69215ac 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -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 index 0000000..ba2e94e --- /dev/null +++ b/src/keymap.cpp @@ -0,0 +1,39 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#include +#include +#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 index 0000000..83d2844 --- /dev/null +++ b/src/keymap.h @@ -0,0 +1,39 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#ifndef __GUILE_IRRLICHT_KEYMAP_H_INCLUDED__ +#define __GUILE_IRRLICHT_KEYMAP_H_INCLUDED__ + +#include +#include +#include "wrapped.h" + +extern "C" { + + void + init_keymap (void); + + DECLARE_WRAPPED_TYPE (irr::SKeyMap*, init_keymap_type, + keymap_p, wrap_keymap, unwrap_keymap); + +} + +#endif diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index 0f3e54c..eb7a378 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -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, diff --git a/src/scene-manager.h b/src/scene-manager.h index 39f020d..41af557 100644 --- a/src/scene-manager.h +++ b/src/scene-manager.h @@ -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, -- 2.39.5