]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
add-camera-scene-node!
authorJavier Sancho <jsf@jsancho.org>
Mon, 16 Mar 2020 19:27:41 +0000 (20:27 +0100)
committerJavier Sancho <jsf@jsancho.org>
Mon, 16 Mar 2020 19:27:41 +0000 (20:27 +0100)
Makefile.am
examples/01.HelloWorld.scm
irrlicht/scene.scm
src/camera-scene-node.cpp [new file with mode: 0644]
src/camera-scene-node.h [new file with mode: 0644]
src/guile-irrlicht.cpp
src/scene-manager.cpp
src/scene-manager.h

index 2a5fc9e5c9603b1b348d99333d9a988b02104deb..a1b60556885802cb1bb6cb2955259e8f1aa51596 100644 (file)
@@ -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 \
index 3f128cb7770d3839213a0f825148165942f81adf..31db92b4ad453bd0cd7b242a29c8742a082f78fe 100644 (file)
 ;; 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)
index f3191a0b808844dd1c112d86e26352b0a79a9eda..115d2e856a5d6477ef57435715b5516cacc0b8bd 100644 (file)
@@ -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!
 
 (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 (file)
index 0000000..7ed90f7
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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 "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 (file)
index 0000000..1b546ba
--- /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_CAMERA_SCENE_NODE_H_INCLUDED__
+#define __GUILE_IRRLICHT_CAMERA_SCENE_NODE_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#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
index 898815e5c00c06a04d8aba2f8f753fb588015143..991f26a166747d0607add1037ac49906cacd5869 100644 (file)
@@ -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 ();
index d4234e8c10c043f799de78d122c2ab26f1f6e2a9..3c080d566439b46e26932de4ee08408783a9bb35 100644 (file)
@@ -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);
+  }
+
 }
index 961b963096ff739cc9334370fa25b6e895398c0a..aa5d442a235ed83fdacadf1bdb4613e78fe2680a 100644 (file)
@@ -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