X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fscene-node.cpp;h=3700818f4c290eeeea6dff21c33f046347b87e7e;hb=3bb58c2b45af12c0f9c9eac648e67ac6fa90e104;hp=c92c2d5dcf45d62ea4d872fc57c80ef78fd2aac3;hpb=d8ff74866c89933d74577d7887e47f013d515c69;p=guile-irrlicht.git diff --git a/src/scene-node.cpp b/src/scene-node.cpp index c92c2d5..3700818 100644 --- a/src/scene-node.cpp +++ b/src/scene-node.cpp @@ -21,84 +21,140 @@ #include #include - -#include "animated-mesh-scene-node.h" -#include "mesh-scene-node.h" +#include "gsubr.h" +#include "material-flags.h" +#include "matrix4.h" #include "scene-node.h" -#include "scene-node-animator.h" -#include "texture.h" #include "vector3d.h" #include "wrapped.h" -extern "C" { - - void - init_scene_node (void) - { - init_scene_node_type (); - scm_c_define_gsubr ("add-animator!", 2, 0, 0, (scm_t_subr)irr_scene_addAnimator); - 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); - } - - DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node", - init_scene_node_type, scene_node_p, - wrap_scene_node, unwrap_scene_node); - - SCM - irr_scene_addAnimator (SCM wrapped_scene_node, - SCM animator) - { - irr::scene::ISceneNode* node = unwrap_scene_node (wrapped_scene_node); - node->addAnimator (unwrap_scene_node_animator (animator)); - return SCM_UNSPECIFIED; - } - - SCM - irr_scene_setMaterialTexture (SCM wrapped_scene_node, - SCM texture_layer, - SCM texture) - { - if (animated_mesh_scene_node_p (wrapped_scene_node)) - { - unwrap_animated_mesh_scene_node (wrapped_scene_node)-> - setMaterialTexture (scm_to_uint32 (texture_layer), - unwrap_texture (texture)); - } - else if (scene_node_p (wrapped_scene_node)) - { - unwrap_scene_node (wrapped_scene_node)-> - setMaterialTexture (scm_to_uint32 (texture_layer), - unwrap_texture (texture)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set material texture to object: ~S", - scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node)); - } - return SCM_UNSPECIFIED; - } - - SCM - irr_scene_setPosition (SCM wrapped_scene_node, - SCM position) - { - if (scene_node_p (wrapped_scene_node)) - { - unwrap_scene_node (wrapped_scene_node)-> - setPosition (scm_to_vector3df (position)); - } - else if (mesh_scene_node_p (wrapped_scene_node)) - { - unwrap_mesh_scene_node (wrapped_scene_node)-> - setPosition (scm_to_vector3df (position)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set position to object: ~S", - scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node)); - } - return SCM_UNSPECIFIED; - } +using namespace irr; + +template +SCM +ISceneNode_addAnimator (SCM scene_node, + SCM animator) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->addAnimator ((scene::ISceneNodeAnimator*) scm_to_irr_pointer (animator)); + return SCM_UNSPECIFIED; +} + +template +SCM +ISceneNode_getAbsoluteTransformation (SCM scene_node) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + return scm_from_matrix4 (node->getAbsoluteTransformation ()); +} + +template +SCM +ISceneNode_getPosition (SCM scene_node) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + return scm_from_vector3df (node->getPosition ()); +} + +template +SCM +ISceneNode_setMaterialFlag (SCM scene_node, + SCM flag, + SCM newvalue) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->setMaterialFlag (scm_to_material_flag (flag), scm_to_bool (newvalue)); + return SCM_UNSPECIFIED; +} + +template +SCM +ISceneNode_setMaterialTexture (SCM scene_node, + SCM texture_layer, + SCM texture) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->setMaterialTexture (scm_to_uint32 (texture_layer), + (video::ITexture*) scm_to_irr_pointer (texture)); + return SCM_UNSPECIFIED; +} + +template +SCM +ISceneNode_setPosition (SCM scene_node, + SCM position) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->setPosition (scm_to_vector3df (position)); + return SCM_UNSPECIFIED; +} + +template +SCM +ISceneNode_setRotation (SCM scene_node, + SCM rotation) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->setRotation (scm_to_vector3df (rotation)); + return SCM_UNSPECIFIED; +} + +template +SCM +ISceneNode_setScale (SCM scene_node, + SCM scale) +{ + TSceneNode node = (TSceneNode) scm_to_irr_pointer (scene_node); + node->setScale (scm_to_vector3df (scale)); + return SCM_UNSPECIFIED; +} + +void +init_scene_node (void) +{ + DEFINE_GSUBR ("IAnimatedMeshSceneNode_addAnimator", 2, 0, 0, + ISceneNode_addAnimator); + DEFINE_GSUBR ("IMeshSceneNode_addAnimator", 2, 0, 0, + ISceneNode_addAnimator); + DEFINE_GSUBR ("ISceneNode_addAnimator", 2, 0, 0, + ISceneNode_addAnimator); + + DEFINE_GSUBR ("ISceneNode_getAbsoluteTransformation", 1, 0, 0, + ISceneNode_getAbsoluteTransformation); + + DEFINE_GSUBR ("IMeshSceneNode_getPosition", 1, 0, 0, + ISceneNode_getPosition); + DEFINE_GSUBR ("ISceneNode_getPosition", 1, 0, 0, + ISceneNode_getPosition); + + DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialFlag", 3, 0, 0, + ISceneNode_setMaterialFlag); + DEFINE_GSUBR ("IMeshSceneNode_setMaterialFlag", 3, 0, 0, + ISceneNode_setMaterialFlag); + DEFINE_GSUBR ("ISceneNode_setMaterialFlag", 3, 0, 0, + ISceneNode_setMaterialFlag); + + DEFINE_GSUBR ("IAnimatedMeshSceneNode_setMaterialTexture", 3, 0, 0, + ISceneNode_setMaterialTexture); + DEFINE_GSUBR ("IMeshSceneNode_setMaterialTexture", 3, 0, 0, + ISceneNode_setMaterialTexture); + DEFINE_GSUBR ("ISceneNode_setMaterialTexture", 3, 0, 0, + ISceneNode_setMaterialTexture); + + DEFINE_GSUBR ("IMeshSceneNode_setPosition", 2, 0, 0, + ISceneNode_setPosition); + DEFINE_GSUBR ("ISceneNode_setPosition", 2, 0, 0, + ISceneNode_setPosition); + + DEFINE_GSUBR ("IAnimatedMeshSceneNode_setRotation", 2, 0, 0, + ISceneNode_setRotation); + DEFINE_GSUBR ("ICameraSceneNode_setRotation", 2, 0, 0, + ISceneNode_setRotation); + DEFINE_GSUBR ("ISceneNode_setRotation", 2, 0, 0, + ISceneNode_setRotation); + DEFINE_GSUBR ("IAnimatedMeshSceneNode_setScale", 2, 0, 0, + ISceneNode_setScale); + DEFINE_GSUBR ("ISceneNode_setScale", 2, 0, 0, + ISceneNode_setScale); }