From: Javier Sancho Date: Sat, 11 Apr 2020 11:28:05 +0000 (+0200) Subject: set-rotation! set-scale! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=68528ba0d56d77a3e803e984237c873515dc9618;p=guile-irrlicht.git set-rotation! set-scale! --- diff --git a/src/scene-node.cpp b/src/scene-node.cpp index 31109ea..50d402b 100644 --- a/src/scene-node.cpp +++ b/src/scene-node.cpp @@ -23,6 +23,7 @@ #include #include "animated-mesh-scene-node.h" +#include "camera-scene-node.h" #include "gsubr.h" #include "material-flags.h" #include "matrix4.h" @@ -42,6 +43,8 @@ extern "C" { DEFINE_GSUBR ("add-animator!", 2, 0, 0, irr_scene_addAnimator); DEFINE_GSUBR ("get-absolute-transformation", 1, 0, 0, irr_scene_getAbsoluteTransformation); DEFINE_GSUBR ("set-material-texture!", 3, 0, 0, irr_scene_setMaterialTexture); + DEFINE_GSUBR ("set-rotation!", 2, 0, 0, irr_scene_setRotation); + DEFINE_GSUBR ("set-scale!", 2, 0, 0, irr_scene_setScale); } DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node", @@ -163,4 +166,54 @@ extern "C" { return SCM_UNSPECIFIED; } + SCM + irr_scene_setRotation (SCM wrapped_scene_node, + SCM rotation) + { +#define SET_ROTATION(NODE) NODE->setRotation (scm_to_vector3df (rotation)); + + if (animated_mesh_scene_node_p (wrapped_scene_node)) + { + SET_ROTATION (unwrap_animated_mesh_scene_node (wrapped_scene_node)); + } + else if (camera_scene_node_p (wrapped_scene_node)) + { + SET_ROTATION (unwrap_camera_scene_node (wrapped_scene_node)); + } + else if (scene_node_p (wrapped_scene_node)) + { + SET_ROTATION (unwrap_scene_node (wrapped_scene_node)); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set rotation to object: ~S", + scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node)); + } + + return SCM_UNSPECIFIED; + } + + SCM + irr_scene_setScale (SCM wrapped_scene_node, + SCM scale) + { +#define SET_SCALE(NODE) NODE->setScale (scm_to_vector3df (scale)); + + if (animated_mesh_scene_node_p (wrapped_scene_node)) + { + SET_SCALE (unwrap_animated_mesh_scene_node (wrapped_scene_node)); + } + else if (scene_node_p (wrapped_scene_node)) + { + SET_SCALE (unwrap_scene_node (wrapped_scene_node)); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set scale to object: ~S", + scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node)); + } + + return SCM_UNSPECIFIED; + } + } diff --git a/src/scene-node.h b/src/scene-node.h index 3246b8b..038601f 100644 --- a/src/scene-node.h +++ b/src/scene-node.h @@ -55,6 +55,14 @@ extern "C" { irr_scene_setPosition (SCM wrapped_scene_node, SCM position); + SCM + irr_scene_setRotation (SCM wrapped_scene_node, + SCM rotation); + + SCM + irr_scene_setScale (SCM wrapped_scene_node, + SCM scale); + } #endif