]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
matrix4
authorJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 08:15:31 +0000 (10:15 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sun, 10 May 2020 08:15:31 +0000 (10:15 +0200)
src/matrix4.cpp
src/matrix4.h

index 2861a0c388b163f1651090250b03c1d3889a2dee..67d58ed81aff315ce9960e87ad75a22ad34b7200 100644 (file)
 #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;
-  }
 
+using namespace irr;
+
+
+SCM
+scm_from_matrix4 (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])));
+}
+
+
+core::matrix4
+scm_to_matrix4 (SCM matrix)
+{
+  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;
 }
index 26530511d5fb9372d6de5bb127fe183ce24440f9..dd3b0305d249e1ad908482077163e5067a50faee 100644 (file)
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 
-extern "C" {
+SCM
+scm_from_matrix4 (irr::core::matrix4 cmatrix);
 
-  SCM
-  scm_from_matrix4 (irr::core::matrix4 cmatrix);
-
-  irr::core::matrix4
-  scm_to_matrix4 (SCM matrix);
-
-}
+irr::core::matrix4
+scm_to_matrix4 (SCM matrix);
 
 #endif