src/keymap.cpp \
src/material.cpp \
src/material-flags.cpp \
+ src/matrix4.cpp \
src/mesh.cpp \
src/mesh-scene-node.cpp \
- src/misc.cpp \
src/position2d.cpp \
src/rect.cpp \
src/reference-counted.cpp \
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "rect.h"
+#include "color.h"
extern "C" {
#include "gui-element.h"
#include "gui-environment.h"
#include "gui-static-text.h"
+#include "guile-irrlicht.h"
#include "keymap.h"
#include "material.h"
#include "material-flags.h"
#include "mesh.h"
#include "mesh-scene-node.h"
-#include "misc.h"
#include "reference-counted.h"
#include "scene-manager.h"
#include "scene-node.h"
#include "texture.h"
#include "vertex3d.h"
#include "video-driver.h"
+#include "wchar.h"
extern "C" {
void
init_guile_irrlicht (void)
{
+ // Init modules
init_animated_mesh ();
init_animated_mesh_scene_node ();
init_box3d ();
init_material_flag ();
init_mesh ();
init_mesh_scene_node ();
- init_misc ();
init_reference_counted ();
init_scene_manager ();
init_scene_node ();
init_texture ();
init_vertex3d ();
init_video_driver ();
+
+ // Shared procedures (used by two or more objects)
+ scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll);
+ scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName);
+ scm_c_define_gsubr ("set-material!", 2, 0, 0, (scm_t_subr)irr_setMaterial);
+ scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition);
+ scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible);
+ scm_c_export ("draw-all", "get-name", "set-material!", "set-position!",
+ "set-visible!", NULL);
+ }
+
+ SCM
+ irr_drawAll (SCM wrapped_obj)
+ {
+ if (gui_environment_p (wrapped_obj))
+ {
+ unwrap_gui_environment (wrapped_obj)->drawAll ();
+ }
+ else if (scene_manager_p (wrapped_obj))
+ {
+ unwrap_scene_manager (wrapped_obj)->drawAll ();
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S",
+ scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+ }
+ return SCM_UNSPECIFIED;
+ }
+
+ SCM
+ irr_getName (SCM wrapped_obj)
+ {
+ if (video_driver_p (wrapped_obj))
+ {
+ return scm_from_wide_char_string (unwrap_video_driver (wrapped_obj)->getName ());
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot get name from object: ~S",
+ scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+ }
+ }
+
+ SCM
+ irr_setMaterial (SCM wrapped_obj,
+ SCM material)
+ {
+ if (video_driver_p (wrapped_obj))
+ {
+ return irr_video_setMaterial (wrapped_obj, material);
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot set material to object: ~S",
+ scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+ }
+ }
+
+ SCM
+ irr_setPosition (SCM wrapped_obj,
+ SCM position)
+ {
+ if (cursor_control_p (wrapped_obj))
+ {
+ return irr_gui_setPosition (wrapped_obj, position);
+ }
+ else if (scene_node_p (wrapped_obj) || mesh_scene_node_p (wrapped_obj))
+ {
+ return irr_scene_setPosition (wrapped_obj, position);
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot set position for object: ~S",
+ scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+ }
+ }
+
+ SCM
+ irr_setVisible (SCM wrapped_obj,
+ SCM visible)
+ {
+ if (cursor_control_p (wrapped_obj))
+ {
+ unwrap_cursor_control (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ else if (gui_element_p (wrapped_obj))
+ {
+ unwrap_gui_element (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ else if (scene_node_p (wrapped_obj))
+ {
+ unwrap_scene_node (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot set visibility for object: ~S",
+ scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+ }
+ return SCM_UNSPECIFIED;
}
}
--- /dev/null
+/* 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_H_INCLUDED__
+#define __GUILE_IRRLICHT_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+extern "C" {
+
+ void
+ init_guile_irrlicht (void);
+
+ SCM
+ irr_drawAll (SCM wrapped_obj);
+
+ SCM
+ irr_getName (SCM wrapped_obj);
+
+ SCM
+ irr_setMaterial (SCM wrapped_obj,
+ SCM material);
+
+ SCM
+ irr_setPosition (SCM wrapped_obj,
+ SCM position);
+
+ SCM
+ irr_setVisible (SCM wrapped_obj,
+ SCM visible);
+
+}
+
+#endif
--- /dev/null
+/* 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 "matrix4.h"
+
+extern "C" {
+
+ SCM
+ scm_from_matrix4 (irr::core::matrix4 cmatrix)
+ {
+ return scm_list_4 (scm_list_4 (scm_from_double (cmatrix[0]),
+ scm_from_double (cmatrix[1]),
+ scm_from_double (cmatrix[2]),
+ scm_from_double (cmatrix[3])),
+ scm_list_4 (scm_from_double (cmatrix[4]),
+ scm_from_double (cmatrix[5]),
+ scm_from_double (cmatrix[6]),
+ scm_from_double (cmatrix[7])),
+ scm_list_4 (scm_from_double (cmatrix[8]),
+ scm_from_double (cmatrix[9]),
+ scm_from_double (cmatrix[10]),
+ scm_from_double (cmatrix[11])),
+ scm_list_4 (scm_from_double (cmatrix[12]),
+ scm_from_double (cmatrix[13]),
+ scm_from_double (cmatrix[14]),
+ scm_from_double (cmatrix[15])));
+ }
+
+ irr::core::matrix4
+ scm_to_matrix4 (SCM matrix)
+ {
+ irr::core::matrix4 cmatrix;
+
+ cmatrix[0] = scm_to_double (scm_car (scm_car (matrix)));
+ cmatrix[1] = scm_to_double (scm_cadr (scm_car (matrix)));
+ cmatrix[2] = scm_to_double (scm_caddr (scm_car (matrix)));
+ cmatrix[3] = scm_to_double (scm_cadddr (scm_car (matrix)));
+
+ cmatrix[4] = scm_to_double (scm_car (scm_cadr (matrix)));
+ cmatrix[5] = scm_to_double (scm_cadr (scm_cadr (matrix)));
+ cmatrix[6] = scm_to_double (scm_caddr (scm_cadr (matrix)));
+ cmatrix[7] = scm_to_double (scm_cadddr (scm_cadr (matrix)));
+
+ cmatrix[8] = scm_to_double (scm_car (scm_caddr (matrix)));
+ cmatrix[9] = scm_to_double (scm_cadr (scm_caddr (matrix)));
+ cmatrix[10] = scm_to_double (scm_caddr (scm_caddr (matrix)));
+ cmatrix[11] = scm_to_double (scm_cadddr (scm_caddr (matrix)));
+
+ cmatrix[12] = scm_to_double (scm_car (scm_cadddr (matrix)));
+ cmatrix[13] = scm_to_double (scm_cadr (scm_cadddr (matrix)));
+ cmatrix[14] = scm_to_double (scm_caddr (scm_cadddr (matrix)));
+ cmatrix[15] = scm_to_double (scm_cadddr (scm_cadddr (matrix)));
+
+ return cmatrix;
+ }
+
+}
--- /dev/null
+/* 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_MATRIX4_H_INCLUDED__
+#define __GUILE_IRRLICHT_MATRIX4_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+extern "C" {
+
+ SCM
+ scm_from_matrix4 (irr::core::matrix4 cmatrix);
+
+ irr::core::matrix4
+ scm_to_matrix4 (SCM matrix);
+
+}
+
+#endif
+++ /dev/null
-/* 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 "cursor-control.h"
-#include "gui-element.h"
-#include "gui-environment.h"
-#include "mesh-scene-node.h"
-#include "misc.h"
-#include "scene-manager.h"
-#include "scene-node.h"
-#include "video-driver.h"
-#include "wchar.h"
-
-extern "C" {
-
- void
- init_misc (void)
- {
- scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll);
- scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName);
- scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition);
- scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible);
- scm_c_export ("draw-all", "get-name", "set-position!", "set-visible!", NULL);
- }
-
- SCM
- irr_drawAll (SCM wrapped_obj)
- {
- if (gui_environment_p (wrapped_obj))
- {
- unwrap_gui_environment (wrapped_obj)->drawAll ();
- }
- else if (scene_manager_p (wrapped_obj))
- {
- unwrap_scene_manager (wrapped_obj)->drawAll ();
- }
- else
- {
- scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S",
- scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
- }
- return SCM_UNSPECIFIED;
- }
-
- SCM
- irr_getName (SCM wrapped_obj)
- {
- if (video_driver_p (wrapped_obj))
- {
- return scm_from_wide_char_string (unwrap_video_driver (wrapped_obj)->getName ());
- }
- else
- {
- scm_error (scm_arg_type_key, NULL, "Cannot get name from object: ~S",
- scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
- }
- }
-
- SCM
- irr_setPosition (SCM wrapped_obj,
- SCM position)
- {
- if (cursor_control_p (wrapped_obj))
- {
- return irr_gui_setPosition (wrapped_obj, position);
- }
- else if (scene_node_p (wrapped_obj) || mesh_scene_node_p (wrapped_obj))
- {
- return irr_scene_setPosition (wrapped_obj, position);
- }
- else
- {
- scm_error (scm_arg_type_key, NULL, "Cannot set position for object: ~S",
- scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
- }
- }
-
- SCM
- irr_setVisible (SCM wrapped_obj,
- SCM visible)
- {
- if (cursor_control_p (wrapped_obj))
- {
- unwrap_cursor_control (wrapped_obj)->setVisible (scm_to_bool (visible));
- }
- else if (gui_element_p (wrapped_obj))
- {
- unwrap_gui_element (wrapped_obj)->setVisible (scm_to_bool (visible));
- }
- else if (scene_node_p (wrapped_obj))
- {
- unwrap_scene_node (wrapped_obj)->setVisible (scm_to_bool (visible));
- }
- else
- {
- scm_error (scm_arg_type_key, NULL, "Cannot set visibility for object: ~S",
- scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
- }
- return SCM_UNSPECIFIED;
- }
-
-}
+++ /dev/null
-/* 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_MISC_H_INCLUDED__
-#define __GUILE_IRRLICHT_MISC_H_INCLUDED__
-
-#include <irrlicht/irrlicht.h>
-#include <libguile.h>
-
-extern "C" {
-
- void
- init_misc (void);
-
- SCM
- irr_drawAll (SCM wrapped_obj);
-
- SCM
- irr_getName (SCM wrapped_obj);
-
- SCM
- irr_setPosition (SCM wrapped_obj,
- SCM position);
-
- SCM
- irr_setVisible (SCM wrapped_obj,
- SCM visible);
-
-}
-
-#endif
#include <libguile.h>
#include "animated-mesh-scene-node.h"
+#include "matrix4.h"
#include "mesh-scene-node.h"
#include "scene-node.h"
#include "scene-node-animator.h"
{
init_scene_node_type ();
scm_c_define_gsubr ("add-animator!", 2, 0, 0, (scm_t_subr)irr_scene_addAnimator);
+ scm_c_define_gsubr ("get-absolute-transformation", 1, 0, 0,
+ (scm_t_subr)irr_scene_getAbsoluteTransformation);
scm_c_define_gsubr ("set-material-texture!", 3, 0, 0, (scm_t_subr)irr_scene_setMaterialTexture);
- scm_c_export ("add-animator!", "set-material-texture!", NULL);
+ scm_c_export ("add-animator!", "get-absolute-transformation",
+ "set-material-texture!", NULL);
}
DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node",
return SCM_UNSPECIFIED;
}
+ SCM
+ irr_scene_getAbsoluteTransformation (SCM wrapped_scene_node)
+ {
+ irr::scene::ISceneNode* node = unwrap_scene_node (wrapped_scene_node);
+ return scm_from_matrix4 (node->getAbsoluteTransformation ());
+ }
+
SCM
irr_scene_setMaterialTexture (SCM wrapped_scene_node,
SCM texture_layer,
irr_scene_addAnimator (SCM wrapped_scene_node,
SCM animator);
+ SCM
+ irr_scene_getAbsoluteTransformation (SCM wrapped_scene_node);
+
SCM
irr_scene_setMaterialTexture (SCM wrapped_scene_node,
SCM texture_layer,
#include "color.h"
#include "device.h"
#include "gui-environment.h"
+#include "material.h"
+#include "matrix4.h"
#include "rect.h"
#include "scene-manager.h"
#include "texture.h"
scm_c_define_gsubr ("get-fps", 1, 0, 0, (scm_t_subr)irr_video_getFPS);
scm_c_define_gsubr ("get-texture", 2, 0, 0, (scm_t_subr)irr_video_getTexture);
scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver);
+ scm_c_define_gsubr ("set-transform!", 3, 0, 0, (scm_t_subr)irr_video_setTransform);
scm_c_export ("begin-scene", "end-scene", "get-fps", "get-texture",
- "get-video-driver", NULL);
+ "get-video-driver", "set-transform!", NULL);
}
DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver",
return wrap_texture (texture);
}
+ SCM
+ irr_video_setMaterial (SCM wrapped_video_driver,
+ SCM material)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ driver->setMaterial (*(unwrap_material (material)));
+ return SCM_UNSPECIFIED;
+ }
+
+ SCM
+ irr_video_setTransform (SCM wrapped_video_driver,
+ SCM state,
+ SCM mat)
+ {
+ irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+ driver->setTransform (scm_to_transformation_state (state),
+ scm_to_matrix4 (mat));
+ return SCM_UNSPECIFIED;
+ }
+
SCM
irr_getVideoDriver (SCM wrapped_obj)
{
return wrap_video_driver (driver);
}
+ irr::video::E_TRANSFORMATION_STATE
+ scm_to_transformation_state (SCM transformation_state)
+ {
+ char* state = scm_to_utf8_stringn (scm_symbol_to_string (transformation_state), NULL);
+ if (!strcmp (state, "view"))
+ {
+ return irr::video::ETS_VIEW;
+ }
+ else if (!strcmp (state, "world"))
+ {
+ return irr::video::ETS_WORLD;
+ }
+ else if (!strcmp (state, "projection"))
+ {
+ return irr::video::ETS_PROJECTION;
+ }
+ else if (!strcmp (state, "texture0"))
+ {
+ return irr::video::ETS_TEXTURE_0;
+ }
+ else if (!strcmp (state, "texture1"))
+ {
+ return irr::video::ETS_TEXTURE_1;
+ }
+ else if (!strcmp (state, "texture2"))
+ {
+ return irr::video::ETS_TEXTURE_2;
+ }
+ else if (!strcmp (state, "texture3"))
+ {
+ return irr::video::ETS_TEXTURE_3;
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Wrong transformation state: ~S",
+ scm_list_1 (transformation_state), scm_list_1 (transformation_state));
+ }
+ }
+
}
irr_video_getTexture (SCM wrapped_video_driver,
SCM filename);
+ SCM
+ irr_video_setMaterial (SCM wrapped_video_driver,
+ SCM material);
+
+ SCM
+ irr_video_setTransform (SCM wrapped_video_driver,
+ SCM state,
+ SCM mat);
+
SCM
irr_getVideoDriver (SCM wrapped_obj);
+ irr::video::E_TRANSFORMATION_STATE
+ scm_to_transformation_state (SCM transformation_state);
+
}
#endif