X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fvertex3d.cpp;h=e0ca2d2cab1ee198e0fd6798ab2740d1f346023c;hb=3bb58c2b45af12c0f9c9eac648e67ac6fa90e104;hp=07a85b9801d8414005ba3e44a8593bfb9d5da57c;hpb=0e0782653487ad1691d7879ff433bc5ffd7c3791;p=guile-irrlicht.git diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp index 07a85b9..e0ca2d2 100644 --- a/src/vertex3d.cpp +++ b/src/vertex3d.cpp @@ -22,37 +22,65 @@ #include #include #include "color.h" +#include "gsubr.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); - } +using namespace irr; +SCM +S3DVertex_make (SCM position, + SCM normal, + SCM color, + SCM tcoords) +{ + video::S3DVertex* vertex = + new video::S3DVertex (scm_to_vector3df (position), + scm_to_vector3df (normal), + scm_to_color (color), + scm_to_vector2df (tcoords)); + return scm_from_irr_pointer ("", (void*) vertex); +} + +SCM +S3DVertex_Pos (SCM vertex) { + video::S3DVertex* s3dvertex = (video::S3DVertex*) scm_to_irr_pointer (vertex); + return scm_from_vector3df (s3dvertex->Pos); +} + +void +init_vertex3d (void) +{ + DEFINE_GSUBR ("S3DVertex_make", 4, 0, 0, S3DVertex_make); + DEFINE_GSUBR ("S3DVertex_Pos", 1, 0, 0, S3DVertex_Pos); +} + +video::E_VERTEX_TYPE +scm_to_vertex_type (SCM vertex_type) +{ + char* type_name = scm_to_utf8_string (scm_symbol_to_string (vertex_type)); + video::E_VERTEX_TYPE type; + + if (!strcmp (type_name, "standard")) + { + type = video::EVT_STANDARD; + } + else if (!strcmp (type_name, "2tcoords")) + { + type = video::EVT_2TCOORDS; + } + else if (!strcmp (type_name, "tangents")) + { + type = video::EVT_TANGENTS; + } + else + { + scm_error (scm_arg_type_key, NULL, "Wrong vertex_type: ~S", + scm_list_1 (vertex_type), scm_list_1 (vertex_type)); + } + + free (type_name); + return type; }