From: Javier Sancho Date: Fri, 27 Mar 2020 07:50:24 +0000 (+0100) Subject: box3d-reset! vertex3d-position X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=commitdiff_plain;h=37217d692d4ead81cfed829395a9a7a5caf9325c box3d-reset! vertex3d-position --- diff --git a/Makefile.am b/Makefile.am index 1e1e331..b2fc266 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,10 +23,10 @@ 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 \ diff --git a/examples/03.CustomSceneNode.scm b/examples/03.CustomSceneNode.scm index 1c0d656..11869fb 100644 --- a/examples/03.CustomSceneNode.scm +++ b/examples/03.CustomSceneNode.scm @@ -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)) @@ -75,17 +75,17 @@ (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 index 47a7eb2..0000000 --- a/src/aabbox3d.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* 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 "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 index 8dda8d3..0000000 --- a/src/aabbox3d.h +++ /dev/null @@ -1,48 +0,0 @@ -/* 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_AABBOX_3D_H_INCLUDED__ -#define __GUILE_IRRLICHT_AABBOX_3D_H_INCLUDED__ - -#include -#include -#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 index 0000000..ee5c65b --- /dev/null +++ b/src/box3d.cpp @@ -0,0 +1,59 @@ +/* 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 "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 index 0000000..8ed47f5 --- /dev/null +++ b/src/box3d.h @@ -0,0 +1,46 @@ +/* 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_AABBOX_3D_H_INCLUDED__ +#define __GUILE_IRRLICHT_AABBOX_3D_H_INCLUDED__ + +#include +#include +#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 diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index c825029..6e7a937 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -21,9 +21,9 @@ #include -#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 (); } diff --git a/src/vector3d.cpp b/src/vector3d.cpp index 85f5bf8..57f5a7d 100644 --- a/src/vector3d.cpp +++ b/src/vector3d.cpp @@ -25,6 +25,14 @@ 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) { diff --git a/src/vector3d.h b/src/vector3d.h index bc7c9f0..c2834ca 100644 --- a/src/vector3d.h +++ b/src/vector3d.h @@ -27,6 +27,9 @@ extern "C" { + SCM + scm_from_vector3df (irr::core::vector3df vector3d); + irr::core::vector3df scm_to_vector3df (SCM vector3d); diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp index 07a85b9..27bf941 100644 --- a/src/vertex3d.cpp +++ b/src/vertex3d.cpp @@ -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); + } + } diff --git a/src/vertex3d.h b/src/vertex3d.h index 4ce2c52..4c033d3 100644 --- a/src/vertex3d.h +++ b/src/vertex3d.h @@ -40,6 +40,9 @@ extern "C" { SCM color, SCM tcoords); + SCM + vertex3d_position (SCM vertex); + } #endif