]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
box3d-reset! vertex3d-position
authorJavier Sancho <jsf@jsancho.org>
Fri, 27 Mar 2020 07:50:24 +0000 (08:50 +0100)
committerJavier Sancho <jsf@jsancho.org>
Fri, 27 Mar 2020 07:50:24 +0000 (08:50 +0100)
Makefile.am
examples/03.CustomSceneNode.scm
src/aabbox3d.cpp [deleted file]
src/aabbox3d.h [deleted file]
src/box3d.cpp [new file with mode: 0644]
src/box3d.h [new file with mode: 0644]
src/guile-irrlicht.cpp
src/vector3d.cpp
src/vector3d.h
src/vertex3d.cpp
src/vertex3d.h

index 1e1e3310b42c557d558bc639fe7c6137c3ad0189..b2fc266772dac5311798b824e2c98e03b29b08b1 100644 (file)
 ACLOCAL_AMFLAGS = -I m4
 lib_LTLIBRARIES = libguile-irrlicht.la
 libguile_irrlicht_la_SOURCES = \
-  src/aabbox3d.cpp \
   src/animated-mesh.cpp \
   src/animated-mesh-md2.cpp \
   src/animated-mesh-scene-node.cpp \
+  src/box3d.cpp \
   src/camera-scene-node.cpp \
   src/color.cpp \
   src/cursor-control.cpp \
index 1c0d65661b5d69a40b10b67fa3ba835dffab822d..11869fbfcae554f6aebf2c20625b17d4af312157 100644 (file)
@@ -67,7 +67,7 @@
                         #:lookat '(0 0 0))
 
 ;; create our custom scene node
-(define box (make-aabbox3df))
+(define box (make-box3d))
 (define vertices
   (list (make-vertex3d '(0 0 10) '(1 1 0) '(255 0 255 255) '(0 1))
         (make-vertex3d '(10 0 -10) '(1 0 0) '(255 255 0 255) '(1 1))
         (make-vertex3d '(-10 0 -10) '(0 0 1) '(255 0 255 0) '(0 0))))
 (define material (make-material #:wireframe #f #:lighting #f))
 
-(aabbox3d-reset! box (vertex-position (car vertices)))
-(for-each (lambda (vertex)
-            (aabbox3d-add-internal-point! box (vertex-position vertex)))
-          (cdr vertices))
+(box3d-reset! box (vertex3d-position (car vertices)))
+(for-each
+ (lambda (vertex)
+   (aabbox3d-add-internal-point! box (vertex3d-position vertex)))
+ (cdr vertices))
 
 (define (custom-render)
   (let ((indices '((0 2 3) (2 1 3) (1 0 3) (2 0 1))))
-    ;;(set-material! driver material)
-    ;;(set-transform! driver 'world (get-absolute-transformation my-node))
-    ;;(draw-vertex-primitive-list driver vertices indices)))
-    #f))
+    (set-material! driver material)
+    (set-transform! driver 'world (get-absolute-transformation my-node))
+    (draw-vertex-primitive-list driver vertices indices)))
 
 (define (custom-get-bounding-box)
   box)
diff --git a/src/aabbox3d.cpp b/src/aabbox3d.cpp
deleted file mode 100644 (file)
index 47a7eb2..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* 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 "aabbox3d.h"
-#include "wrapped.h"
-
-extern "C" {
-
-  void
-  init_aabbox3d (void)
-  {
-    init_aabbox3df_type ();
-    init_aabbox3di_type ();
-    scm_c_define_gsubr ("make-aabbox3df", 0, 0, 0, (scm_t_subr)make_aabbox3df);
-    scm_c_define_gsubr ("make-aabbox3di", 0, 0, 0, (scm_t_subr)make_aabbox3di);
-    scm_c_export ("make-aabbox3df", "make-aabbox3di", NULL);
-  }
-
-  DEFINE_WRAPPED_TYPE (irr::core::aabbox3df*, "aabbox3df",
-                       init_aabbox3df_type, aabbox3df_p,
-                       wrap_aabbox3df, unwrap_aabbox3df);
-
-  DEFINE_WRAPPED_TYPE (irr::core::aabbox3di*, "aabbox3di",
-                       init_aabbox3di_type, aabbox3di_p,
-                       wrap_aabbox3di, unwrap_aabbox3di);
-
-  SCM
-  make_aabbox3df ()
-  {
-    irr::core::aabbox3df* box = new irr::core::aabbox3df ();
-    return wrap_aabbox3df (box);
-  }
-
-  SCM
-  make_aabbox3di ()
-  {
-    irr::core::aabbox3di* box = new irr::core::aabbox3di ();
-    return wrap_aabbox3di (box);
-  }
-
-}
diff --git a/src/aabbox3d.h b/src/aabbox3d.h
deleted file mode 100644 (file)
index 8dda8d3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* 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_AABBOX_3D_H_INCLUDED__
-#define __GUILE_IRRLICHT_AABBOX_3D_H_INCLUDED__
-
-#include <irrlicht/irrlicht.h>
-#include <libguile.h>
-#include "wrapped.h"
-
-extern "C" {
-
-  void
-  init_aabbox3d (void);
-
-  DECLARE_WRAPPED_TYPE (irr::core::aabbox3df*, init_aabbox3df_type,
-                        aabbox3df_p, wrap_aabbox3df, unwrap_aabbox3df);
-
-  DECLARE_WRAPPED_TYPE (irr::core::aabbox3di*, init_aabbox3di_type,
-                        aabbox3di_p, wrap_aabbox3di, unwrap_aabbox3di);
-
-  SCM
-  make_aabbox3df ();
-
-  SCM
-  make_aabbox3di ();
-
-}
-
-#endif
diff --git a/src/box3d.cpp b/src/box3d.cpp
new file mode 100644 (file)
index 0000000..ee5c65b
--- /dev/null
@@ -0,0 +1,59 @@
+/* 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 "box3d.h"
+#include "vector3d.h"
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_box3d (void)
+  {
+    init_box3d_type ();
+    scm_c_define_gsubr ("box3d-reset!", 2, 0, 0, (scm_t_subr)box3d_reset);
+    scm_c_define_gsubr ("make-box3d", 0, 0, 0, (scm_t_subr)make_box3d);
+    scm_c_export ("box3d-reset!", "make-box3d", NULL);
+  }
+
+  DEFINE_WRAPPED_TYPE (irr::core::aabbox3df*, "box3d",
+                       init_box3d_type, box3d_p,
+                       wrap_box3d, unwrap_box3d);
+
+  SCM
+  box3d_reset (SCM box3d,
+               SCM init_value)
+  {
+    irr::core::aabbox3df* aabbox = unwrap_box3d (box3d);
+    aabbox->reset (scm_to_vector3df (init_value));
+    return SCM_UNSPECIFIED;
+  }
+
+  SCM
+  make_box3d ()
+  {
+    irr::core::aabbox3df* aabbox = new irr::core::aabbox3df ();
+    return wrap_box3d (aabbox);
+  }
+
+}
diff --git a/src/box3d.h b/src/box3d.h
new file mode 100644 (file)
index 0000000..8ed47f5
--- /dev/null
@@ -0,0 +1,46 @@
+/* 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_AABBOX_3D_H_INCLUDED__
+#define __GUILE_IRRLICHT_AABBOX_3D_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_box3d (void);
+
+  DECLARE_WRAPPED_TYPE (irr::core::aabbox3df*, init_box3d_type,
+                        box3d_p, wrap_box3d, unwrap_box3d);
+
+  SCM
+  box3d_reset (SCM box3d,
+               SCM init_value);
+
+  SCM
+  make_box3d ();
+
+}
+
+#endif
index c8250291cc9f0ba4627b7a79b877edcc811a8164..6e7a937ea8d6c155e007adf92bd13696ccdc1c2c 100644 (file)
@@ -21,9 +21,9 @@
 
 #include <libguile.h>
 
-#include "aabbox3d.h"
 #include "animated-mesh.h"
 #include "animated-mesh-scene-node.h"
+#include "box3d.h"
 #include "camera-scene-node.h"
 #include "cursor-control.h"
 #include "device.h"
@@ -50,10 +50,9 @@ extern "C" {
   void
   init_guile_irrlicht (void)
   {
-    init_vertex3d ();
-    init_aabbox3d ();
     init_animated_mesh ();
     init_animated_mesh_scene_node ();
+    init_box3d ();
     init_camera_scene_node ();
     init_cursor_control ();
     init_device ();
@@ -72,6 +71,7 @@ extern "C" {
     init_scene_manager ();
     init_scene_node ();
     init_texture ();
+    init_vertex3d ();
     init_video_driver ();
   }
 
index 85f5bf86223c18cca32660e5d8046cba0c8ce99e..57f5a7dbe0d52605f6bc85dbf6309defdb1d56d3 100644 (file)
 
 extern "C" {
 
+  SCM
+  scm_from_vector3df (irr::core::vector3df vector3d)
+  {
+    return scm_list_3 (scm_from_double (vector3d.X),
+                       scm_from_double (vector3d.Y),
+                       scm_from_double (vector3d.Z));
+  }
+
   irr::core::vector3df
   scm_to_vector3df (SCM vector3d)
   {
index bc7c9f0389f2f53801cfe43e1cd775b4d0126b0a..c2834ca39d0a39ebb34ffa1dc90542d4d512d7b7 100644 (file)
@@ -27,6 +27,9 @@
 
 extern "C" {
 
+  SCM
+  scm_from_vector3df (irr::core::vector3df vector3d);
+
   irr::core::vector3df
   scm_to_vector3df (SCM vector3d);
 
index 07a85b9801d8414005ba3e44a8593bfb9d5da57c..27bf94137077833fa97a6351df6fe9bc17401f81 100644 (file)
@@ -34,7 +34,8 @@ extern "C" {
   {
     init_vertex3d_type ();
     scm_c_define_gsubr ("make-vertex3d", 4, 0, 0, (scm_t_subr)make_vertex3d);
-    scm_c_export ("make-vertex3d", NULL);
+    scm_c_define_gsubr ("vertex3d-position", 1, 0, 0, (scm_t_subr)vertex3d_position);
+    scm_c_export ("make-vertex3d", "vertex3d-position", NULL);
   }
 
   DEFINE_WRAPPED_TYPE (irr::video::S3DVertex*, "vertex3d",
@@ -55,4 +56,10 @@ extern "C" {
     return wrap_vertex3d (vertex);
   }
 
+  SCM
+  vertex3d_position (SCM vertex) {
+    irr::video::S3DVertex* s3dvertex = unwrap_vertex3d (vertex);
+    return scm_from_vector3df (s3dvertex->Pos);
+  }
+
 }
index 4ce2c52fab7a57169f761f0808ce356bb97d40fd..4c033d3e6414e079287c934c5371524ed61c5c14 100644 (file)
@@ -40,6 +40,9 @@ extern "C" {
                  SCM color,
                  SCM tcoords);
 
+  SCM
+  vertex3d_position (SCM vertex);
+
 }
 
 #endif