From 0e0782653487ad1691d7879ff433bc5ffd7c3791 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 25 Mar 2020 08:52:40 +0100 Subject: [PATCH] make-vertex3d --- Makefile.am | 2 ++ examples/03.CustomSceneNode.scm | 8 ++--- src/guile-irrlicht.cpp | 2 ++ src/vector2d.cpp | 36 ++++++++++++++++++++ src/vector2d.h | 35 ++++++++++++++++++++ src/vertex3d.cpp | 58 +++++++++++++++++++++++++++++++++ src/vertex3d.h | 45 +++++++++++++++++++++++++ 7 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 src/vector2d.cpp create mode 100644 src/vector2d.h create mode 100644 src/vertex3d.cpp create mode 100644 src/vertex3d.h diff --git a/Makefile.am b/Makefile.am index 4101951..968673b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,7 +50,9 @@ libguile_irrlicht_la_SOURCES = \ src/scene-manager.cpp \ src/scene-node.cpp \ src/texture.cpp \ + src/vector2d.cpp \ src/vector3d.cpp \ + src/vertex3d.cpp \ src/video-driver.cpp \ src/wchar.cpp libguile_irrlicht_la_CPPFLAGS = @GUILE_CFLAGS@ diff --git a/examples/03.CustomSceneNode.scm b/examples/03.CustomSceneNode.scm index 46e35fd..1c0d656 100644 --- a/examples/03.CustomSceneNode.scm +++ b/examples/03.CustomSceneNode.scm @@ -69,10 +69,10 @@ ;; create our custom scene node (define box (make-aabbox3df)) (define vertices - (list (make-s3dvertex '(0 0 10) '(1 1 0) '(255 0 255 255) '(0 1)) - (make-s3dvertex '(10 0 -10) '(1 0 0) '(255 255 0 255) '(1 1)) - (make-s3dvertex '(0 20 0) '(0 1 1) '(255 255 255 0) '(1 0)) - (make-s3dvertex '(-10 0 -10) '(0 0 1) '(255 0 255 0) '(0 0)))) + (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 '(0 20 0) '(0 1 1) '(255 255 255 0) '(1 0)) + (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))) diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index 271ca91..1cc0503 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -41,6 +41,7 @@ #include "scene-manager.h" #include "scene-node.h" #include "texture.h" +#include "vertex3d.h" #include "video-driver.h" extern "C" { @@ -48,6 +49,7 @@ extern "C" { void init_guile_irrlicht (void) { + init_vertex3d (); init_aabbox3d (); init_animated_mesh (); init_animated_mesh_scene_node (); diff --git a/src/vector2d.cpp b/src/vector2d.cpp new file mode 100644 index 0000000..9e46868 --- /dev/null +++ b/src/vector2d.cpp @@ -0,0 +1,36 @@ +/* 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 "vector2d.h" + +extern "C" { + + irr::core::vector2df + scm_to_vector2df (SCM vector2d) + { + return irr::core::vector2df + (scm_to_double (scm_car (vector2d)), + scm_to_double (scm_cadr (vector2d))); + } + +} diff --git a/src/vector2d.h b/src/vector2d.h new file mode 100644 index 0000000..abf3461 --- /dev/null +++ b/src/vector2d.h @@ -0,0 +1,35 @@ +/* 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_VECTOR_2D_H_INCLUDED__ +#define __GUILE_IRRLICHT_VECTOR_2D_H_INCLUDED__ + +#include +#include + +extern "C" { + + irr::core::vector2df + scm_to_vector2df (SCM vector2d); + +} + +#endif diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp new file mode 100644 index 0000000..07a85b9 --- /dev/null +++ b/src/vertex3d.cpp @@ -0,0 +1,58 @@ +/* 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 "color.h" +#include "vector2d.h" +#include "vector3d.h" +#include "vertex3d.h" +#include "wrapped.h" + +extern "C" { + + void + init_vertex3d (void) + { + init_vertex3d_type (); + scm_c_define_gsubr ("make-vertex3d", 4, 0, 0, (scm_t_subr)make_vertex3d); + scm_c_export ("make-vertex3d", NULL); + } + + DEFINE_WRAPPED_TYPE (irr::video::S3DVertex*, "vertex3d", + init_vertex3d_type, vertex3d_p, + wrap_vertex3d, unwrap_vertex3d); + + SCM + make_vertex3d (SCM position, + SCM normal, + SCM color, + SCM tcoords) + { + irr::video::S3DVertex* vertex = + new irr::video::S3DVertex (scm_to_vector3df (position), + scm_to_vector3df (normal), + scm_to_color (color), + scm_to_vector2df (tcoords)); + return wrap_vertex3d (vertex); + } + +} diff --git a/src/vertex3d.h b/src/vertex3d.h new file mode 100644 index 0000000..4ce2c52 --- /dev/null +++ b/src/vertex3d.h @@ -0,0 +1,45 @@ +/* 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_VERTEX_3D_H_INCLUDED__ +#define __GUILE_IRRLICHT_VERTEX_3D_H_INCLUDED__ + +#include +#include +#include "wrapped.h" + +extern "C" { + + void + init_vertex3d (void); + + DECLARE_WRAPPED_TYPE (irr::video::S3DVertex*, init_vertex3d_type, + vertex3d_p, wrap_vertex3d, unwrap_vertex3d); + + SCM + make_vertex3d (SCM position, + SCM normal, + SCM color, + SCM tcoords); + +} + +#endif -- 2.39.2