From: Javier Sancho Date: Mon, 16 Mar 2020 19:27:41 +0000 (+0100) Subject: add-camera-scene-node! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=626e88180d4a966f12defc721c4a4411451ea916;p=guile-irrlicht.git add-camera-scene-node! --- diff --git a/Makefile.am b/Makefile.am index 2a5fc9e..a1b6055 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,7 @@ libguile_irrlicht_la_SOURCES = \ src/animated-mesh.cpp \ src/animated-mesh-md2.cpp \ src/animated-mesh-scene-node.cpp \ + src/camera-scene-node.cpp \ src/device.cpp \ src/dimension2d.cpp \ src/driver-types.cpp \ diff --git a/examples/01.HelloWorld.scm b/examples/01.HelloWorld.scm index 3f128cb..31db92b 100644 --- a/examples/01.HelloWorld.scm +++ b/examples/01.HelloWorld.scm @@ -48,10 +48,10 @@ ;; load a Quake2 model (define mesh (get-mesh scene-manager "media/sydney.md2")) (when (not mesh) - (device-drop! device) + (drop! device) (exit #f)) -(define node (add-animated-mesh-scene-node scene-manager mesh)) +(define node (add-animated-mesh-scene-node! scene-manager mesh)) (when node (set-material-flag! node 'lighting #f) (set-md2-animation! node 'stand) @@ -68,5 +68,5 @@ (end-scene driver)) ;; delete device -(device-drop! device) +(drop! device) (exit #t) diff --git a/irrlicht/scene.scm b/irrlicht/scene.scm index f3191a0..115d2e8 100644 --- a/irrlicht/scene.scm +++ b/irrlicht/scene.scm @@ -19,7 +19,8 @@ (define-module (irrlicht scene) - #:export (add-animated-mesh-scene-node + #:export (add-animated-mesh-scene-node! + add-camera-scene-node! get-mesh set-material-flag! set-material-texture! @@ -27,20 +28,35 @@ (load-extension "libguile-irrlicht" "init_guile_irrlicht") -(define irr-add-animated-mesh-scene-node add-animated-mesh-scene-node) -(define* (add-animated-mesh-scene-node scene-manager mesh - #:key - (parent #f) - (id -1) - (position '(0 0 0)) - (rotation '(0 0 0)) - (scale '(1 1 1)) - (also-add-if-mesh-pointer-zero #f)) - (irr-add-animated-mesh-scene-node scene-manager - mesh - parent - id - position - rotation - scale - also-add-if-mesh-pointer-zero)) +(define irr-add-animated-mesh-scene-node! add-animated-mesh-scene-node!) +(define* (add-animated-mesh-scene-node! scene-manager mesh + #:key + (parent #f) + (id -1) + (position '(0 0 0)) + (rotation '(0 0 0)) + (scale '(1 1 1)) + (also-add-if-mesh-pointer-zero #f)) + (irr-add-animated-mesh-scene-node! scene-manager + mesh + parent + id + position + rotation + scale + also-add-if-mesh-pointer-zero)) + +(define irr-add-camera-scene-node! add-camera-scene-node!) +(define* (add-camera-scene-node! scene-manager + #:key + (parent #f) + (position '(0 0 0)) + (lookat '(0 0 100)) + (id -1) + (make-active #t)) + (irr-add-camera-scene-node! scene-manager + parent + position + lookat + id + make-active)) diff --git a/src/camera-scene-node.cpp b/src/camera-scene-node.cpp new file mode 100644 index 0000000..7ed90f7 --- /dev/null +++ b/src/camera-scene-node.cpp @@ -0,0 +1,38 @@ +/* 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 "camera-scene-node.h" + +extern "C" { + + void + init_camera_scene_node (void) + { + init_camera_scene_node_type (); + } + + DEFINE_WRAPPED_TYPE (irr::scene::ICameraSceneNode*, "camera_scene_node", + init_camera_scene_node_type, camera_scene_node_p, + wrap_camera_scene_node, unwrap_camera_scene_node); + +} diff --git a/src/camera-scene-node.h b/src/camera-scene-node.h new file mode 100644 index 0000000..1b546ba --- /dev/null +++ b/src/camera-scene-node.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_CAMERA_SCENE_NODE_H_INCLUDED__ +#define __GUILE_IRRLICHT_CAMERA_SCENE_NODE_H_INCLUDED__ + +#include +#include +#include "wrapped.h" + +extern "C" { + + void + init_camera_scene_node (void); + + DECLARE_WRAPPED_TYPE (irr::scene::ICameraSceneNode*, init_camera_scene_node_type, + camera_scene_node_p, wrap_camera_scene_node, unwrap_camera_scene_node); + +} + +#endif diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index 898815e..991f26a 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -23,6 +23,7 @@ #include "animated-mesh.h" #include "animated-mesh-scene-node.h" +#include "camera-scene-node.h" #include "device.h" #include "gui-element.h" #include "gui-environment.h" @@ -41,6 +42,7 @@ extern "C" { { init_animated_mesh (); init_animated_mesh_scene_node (); + init_camera_scene_node (); init_device (); init_gui_element (); init_gui_environment (); diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index d4234e8..3c080d5 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -24,6 +24,7 @@ #include "animated-mesh.h" #include "animated-mesh-scene-node.h" +#include "camera-scene-node.h" #include "device.h" #include "scene-manager.h" #include "scene-node.h" @@ -36,8 +37,10 @@ extern "C" { init_scene_manager (void) { init_scene_manager_type (); - scm_c_define_gsubr ("add-animated-mesh-scene-node", 8, 0, 0, + scm_c_define_gsubr ("add-animated-mesh-scene-node!", 8, 0, 0, (scm_t_subr)irr_scene_addAnimatedMeshSceneNode); + scm_c_define_gsubr ("add-camera-scene-node!", 6, 0, 0, + (scm_t_subr)irr_scene_addCameraSceneNode); 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); } @@ -46,22 +49,6 @@ extern "C" { init_scene_manager_type, scene_manager_p, wrap_scene_manager, unwrap_scene_manager); - 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); - } - SCM irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager, SCM mesh, @@ -84,6 +71,24 @@ extern "C" { return wrap_animated_mesh_scene_node (node); } + SCM + irr_scene_addCameraSceneNode (SCM wrapped_scene_manager, + SCM parent, + SCM position, + SCM lookat, + SCM id, + SCM make_active) + { + 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), + scm_to_vector3df (position), + scm_to_vector3df (lookat), + scm_to_int32 (id), + scm_to_bool (make_active)); + return wrap_camera_scene_node (camera); + } + SCM irr_scene_getMesh (SCM wrapped_scene_manager, SCM filename) @@ -93,4 +98,20 @@ extern "C" { return wrap_animated_mesh (mesh); } + 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); + } + } diff --git a/src/scene-manager.h b/src/scene-manager.h index 961b963..aa5d442 100644 --- a/src/scene-manager.h +++ b/src/scene-manager.h @@ -34,9 +34,6 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::scene::ISceneManager*, init_scene_manager_type, scene_manager_p, wrap_scene_manager, unwrap_scene_manager); - SCM - irr_getSceneManager (SCM wrapped_obj); - SCM irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager, SCM mesh, @@ -46,10 +43,22 @@ extern "C" { SCM rotation, SCM scale, SCM alsoAddIfMeshPointerZero); + + SCM + irr_scene_addCameraSceneNode (SCM wrapped_scene_manager, + SCM parent, + SCM position, + SCM lookat, + SCM id, + SCM make_active); + SCM irr_scene_getMesh (SCM wrapped_scene_manager, SCM filename); + SCM + irr_getSceneManager (SCM wrapped_obj); + } #endif