]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
add-octree-scene-node!
authorJavier Sancho <jsf@jsancho.org>
Sat, 21 Mar 2020 07:47:57 +0000 (08:47 +0100)
committerJavier Sancho <jsf@jsancho.org>
Sat, 21 Mar 2020 07:47:57 +0000 (08:47 +0100)
Makefile.am
examples/02.Quake3Map.scm
src/guile-irrlicht.cpp
src/mesh-scene-node.cpp [new file with mode: 0644]
src/mesh-scene-node.h [new file with mode: 0644]
src/mesh.cpp [new file with mode: 0644]
src/mesh.h [new file with mode: 0644]
src/scene-manager.cpp
src/scene-manager.h

index 4918fc260086d9e5bb3b94299e29c8221337f1f4..6b42a54f976c558b4ad165e4e1ebd700a014b91f 100644 (file)
@@ -38,6 +38,8 @@ libguile_irrlicht_la_SOURCES = \
   src/gui-static-text.cpp \
   src/guile-irrlicht.cpp \
   src/material-flags.cpp \
+  src/mesh.cpp \
+  src/mesh-scene-node.cpp \
   src/misc.cpp \
   src/rect.cpp \
   src/reference-counted.cpp \
index 1407f29159abc5ba97956c2b2b4958019f28e5a2..47c81254b679a84f2e213aa9327a9d8006f7c49d 100644 (file)
@@ -65,7 +65,7 @@
 (add-file-archive! (get-file-system device) "media/map-20kdm2.pk3")
 
 (define mesh (get-mesh scene-manager "20kdm2.bsp"))
-(define node (add-octree-scene-node
+(define node (add-octree-scene-node!
               scene-manager mesh
               #:minimal-polys-per-node 1024))
 (set-position! node '(-1300 -144 -1249))
index daa314d5f68e6bdebc3d8849f14ba8140a045f10..4846b693b0b21359fb5e164d430c61fbea89e992 100644 (file)
@@ -31,6 +31,8 @@
 #include "gui-environment.h"
 #include "gui-static-text.h"
 #include "material-flags.h"
+#include "mesh.h"
+#include "mesh-scene-node.h"
 #include "misc.h"
 #include "reference-counted.h"
 #include "scene-manager.h"
@@ -53,6 +55,8 @@ extern "C" {
     init_gui_environment ();
     init_gui_static_text ();
     init_material_flag ();
+    init_mesh ();
+    init_mesh_scene_node ();
     init_misc ();
     init_reference_counted ();
     init_scene_manager ();
diff --git a/src/mesh-scene-node.cpp b/src/mesh-scene-node.cpp
new file mode 100644 (file)
index 0000000..01a2dea
--- /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 "mesh-scene-node.h"
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_mesh_scene_node (void)
+  {
+    init_mesh_scene_node_type ();
+  }
+
+  DEFINE_WRAPPED_TYPE (irr::scene::IMeshSceneNode*, "mesh-scene-node",
+                       init_mesh_scene_node_type, mesh_scene_node_p,
+                       wrap_mesh_scene_node, unwrap_mesh_scene_node);
+
+}
diff --git a/src/mesh-scene-node.h b/src/mesh-scene-node.h
new file mode 100644 (file)
index 0000000..ba1477c
--- /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_MESH_SCENE_NODE_H_INCLUDED__
+#define __GUILE_IRRLICHT_MESH_SCENE_NODE_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_mesh_scene_node (void);
+
+  DECLARE_WRAPPED_TYPE (irr::scene::IMeshSceneNode*, init_mesh_scene_node_type,
+                        mesh_scene_node_p, wrap_mesh_scene_node, unwrap_mesh_scene_node);
+
+}
+
+#endif
diff --git a/src/mesh.cpp b/src/mesh.cpp
new file mode 100644 (file)
index 0000000..e95b81a
--- /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 "mesh.h"
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_mesh (void)
+  {
+    init_mesh_type ();
+  }
+
+  DEFINE_WRAPPED_TYPE (irr::scene::IMesh*, "mesh",
+                       init_mesh_type, mesh_p,
+                       wrap_mesh, unwrap_mesh);
+
+}
diff --git a/src/mesh.h b/src/mesh.h
new file mode 100644 (file)
index 0000000..895a216
--- /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_MESH_H_INCLUDED__
+#define __GUILE_IRRLICHT_MESH_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_mesh (void);
+
+  DECLARE_WRAPPED_TYPE (irr::scene::IMesh*, init_mesh_type,
+                        mesh_p, wrap_mesh, unwrap_mesh);
+
+}
+
+#endif
index cb7f80c94d0249106ff105ae3d39b0a91e5fa681..0f3e54cdae86130a56d8675dbc4364ca971ec9a9 100644 (file)
@@ -26,6 +26,8 @@
 #include "animated-mesh-scene-node.h"
 #include "camera-scene-node.h"
 #include "device.h"
+#include "mesh.h"
+#include "mesh-scene-node.h"
 #include "scene-manager.h"
 #include "scene-node.h"
 #include "vector3d.h"
@@ -41,10 +43,12 @@ 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-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!",
-                  "get-mesh", "get-scene-manager", NULL);
+                  "add-octree-scene-node!", "get-mesh", "get-scene-manager", NULL);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
@@ -122,6 +126,44 @@ extern "C" {
     return wrap_camera_scene_node (camera);
   }
 
+  SCM
+  irr_scene_addOctreeSceneNode (SCM wrapped_scene_manager,
+                                SCM wrapped_mesh,
+                                SCM rest)
+  {
+    SCM parent = scm_from_bool (0);
+    SCM id = scm_from_int32 (-1);
+    SCM minimal_polys_per_node = scm_from_int32 (256);
+    SCM also_add_if_mesh_pointer_zero = scm_from_bool (0);
+
+    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),
+                                         scm_is_false (parent) ? 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),
+                                         scm_is_false (parent) ? 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
   irr_scene_getMesh (SCM wrapped_scene_manager,
                      SCM filename)
index f65548ef68edb7e316f7bab0358db919fffcb5b1..39f020d603aba955c80b102828f7e3688b68360e 100644 (file)
@@ -43,6 +43,11 @@ extern "C" {
   irr_scene_addCameraSceneNode (SCM wrapped_scene_manager,
                                 SCM rest);
 
+  SCM
+  irr_scene_addOctreeSceneNode (SCM wrapped_scene_manager,
+                                SCM wrapped_mesh,
+                                SCM rest);
+
   SCM
   irr_scene_getMesh (SCM wrapped_scene_manager,
                      SCM filename);