From: Javier Sancho Date: Tue, 7 Apr 2020 18:51:10 +0000 (+0200) Subject: add-sphere-scene-node! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=e88bb6a9636fd75d12e71993cac35b9d4cff0d77;p=guile-irrlicht.git add-sphere-scene-node! --- diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index f5d1bf7..1414989 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -53,6 +53,8 @@ extern "C" { (scm_t_subr)irr_scene_addCustomSceneNode); scm_c_define_gsubr ("add-octree-scene-node!", 2, 0, 1, (scm_t_subr)irr_scene_addOctreeSceneNode); + scm_c_define_gsubr ("add-sphere-scene-node!", 1, 0, 1, + (scm_t_subr)irr_scene_addSphereSceneNode); scm_c_define_gsubr ("create-rotation-animator", 2, 0, 0, (scm_t_subr)irr_scene_createRotationAnimator); scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh); @@ -60,8 +62,8 @@ extern "C" { scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager); scm_c_export ("add-animated-mesh-scene-node!", "add-camera-scene-node!", "add-camera-scene-node-fps!", "add-custom-scene-node!", - "add-octree-scene-node!", "create-rotation-animator", - "get-mesh", "get-root-scene-node", + "add-octree-scene-node!", "add-sphere-scene-node!", + "create-rotation-animator", "get-mesh", "get-root-scene-node", "get-scene-manager", NULL); } @@ -323,13 +325,53 @@ extern "C" { return wrap_mesh_scene_node (node); } + SCM + irr_scene_addSphereSceneNode (SCM wrapped_scene_manager, + SCM rest) + { + SCM radius = scm_from_double (5.0); + SCM poly_count = scm_from_int32 (16); + SCM parent = scm_from_bool (0); + SCM id = scm_from_int32 (-1); + SCM position = scm_list_3 (scm_from_double (0), + scm_from_double (0), + scm_from_double (0)); + SCM rotation = scm_list_3 (scm_from_double (0), + scm_from_double (0), + scm_from_double (0)); + SCM scale = scm_list_3 (scm_from_double (1), + scm_from_double (1), + scm_from_double (1)); + + scm_c_bind_keyword_arguments ("add-sphere-scene-node!", rest, (scm_t_keyword_arguments_flags)0, + scm_from_utf8_keyword ("radius"), &radius, + scm_from_utf8_keyword ("poly-count"), &poly_count, + scm_from_utf8_keyword ("parent"), &parent, + scm_from_utf8_keyword ("id"), &id, + scm_from_utf8_keyword ("position"), &position, + scm_from_utf8_keyword ("rotation"), &rotation, + scm_from_utf8_keyword ("scale"), &scale, + SCM_UNDEFINED); + + irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager); + irr::scene::IMeshSceneNode* node = + smgr->addSphereSceneNode (scm_to_double (radius), + scm_to_int32 (poly_count), + scm_is_false (parent) ? 0 : unwrap_scene_node (parent), + scm_to_int32 (id), + scm_to_vector3df (position), + scm_to_vector3df (rotation), + scm_to_vector3df (scale)); + return wrap_mesh_scene_node (node); + } + SCM irr_scene_createRotationAnimator (SCM wrapped_scene_manager, SCM rotation_speed) { irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager); irr::scene::ISceneNodeAnimator* anim = - smgr->createRotationAnimator(scm_to_vector3df (rotation_speed)); + smgr->createRotationAnimator (scm_to_vector3df (rotation_speed)); return wrap_scene_node_animator (anim); } diff --git a/src/scene-manager.h b/src/scene-manager.h index 5da8358..7b6e7c5 100644 --- a/src/scene-manager.h +++ b/src/scene-manager.h @@ -60,6 +60,10 @@ extern "C" { SCM wrapped_mesh, SCM rest); + SCM + irr_scene_addSphereSceneNode (SCM wrapped_scene_manager, + SCM rest); + SCM irr_scene_createRotationAnimator (SCM wrapped_scene_manager, SCM rotation_speed);