summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-09-16 00:55:53 -0500
committersanine <sanine.not@pm.me>2022-09-16 00:55:53 -0500
commitd444d1c98fdefea6cf0aff50eb9b58d4dbcea6ed (patch)
treead4f0fea5d8f0d0b581978d50debccb63b3e6b38 /src
parentf2eb020c4199134e07632f3c6690d68381837b85 (diff)
begin assimp bindings
Diffstat (limited to 'src')
-rw-r--r--src/import/CMakeLists.txt10
-rw-r--r--src/import/import.c14
-rw-r--r--src/import/import.h0
-rw-r--r--src/import/import.test.c44
4 files changed, 68 insertions, 0 deletions
diff --git a/src/import/CMakeLists.txt b/src/import/CMakeLists.txt
new file mode 100644
index 0000000..fc35779
--- /dev/null
+++ b/src/import/CMakeLists.txt
@@ -0,0 +1,10 @@
+project(honey_engine)
+
+target_sources(honey PUBLIC
+ ${CMAKE_CURRENT_LIST_DIR}/import.c
+)
+
+
+target_sources(test PUBLIC
+ ${CMAKE_CURRENT_LIST_DIR}/import.test.c
+)
diff --git a/src/import/import.c b/src/import/import.c
new file mode 100644
index 0000000..cc22616
--- /dev/null
+++ b/src/import/import.c
@@ -0,0 +1,14 @@
+#include <lua.h>
+#include <honeysuckle.h>
+#include <assimp/scene.h>
+#include "import.h"
+
+
+void push_vector(lua_State *L, struct aiVector3D vec)
+{
+ hs_create_table(L,
+ hs_str_num("x", vec.x),
+ hs_str_num("y", vec.y),
+ hs_str_num("z", vec.z),
+ );
+}
diff --git a/src/import/import.h b/src/import/import.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/import/import.h
diff --git a/src/import/import.test.c b/src/import/import.test.c
new file mode 100644
index 0000000..efa6b84
--- /dev/null
+++ b/src/import/import.test.c
@@ -0,0 +1,44 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <honeysuckle.h>
+#include "test/honey-test.h"
+
+
+#include "import.c"
+
+
+void test_push_vector()
+{
+ lua_State *L = luaL_newstate();
+ struct aiVector3D v;
+ v.x = 1.5;
+ v.y = 2.0;
+ v.z = 3.6;
+
+ push_vector(L, v);
+
+ lily_assert_int_equal(lua_type(L, -1), LUA_TTABLE);
+
+ lua_getfield(L, -1, "x");
+ lily_assert_int_equal(lua_type(L, -1), LUA_TNUMBER);
+ lily_assert_float_equal(lua_tonumber(L, -1), 1.5, 0.1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "y");
+ lily_assert_int_equal(lua_type(L, -1), LUA_TNUMBER);
+ lily_assert_float_equal(lua_tonumber(L, -1), 2.0, 0.1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "z");
+ lily_assert_int_equal(lua_type(L, -1), LUA_TNUMBER);
+ lily_assert_float_equal(lua_tonumber(L, -1), 3.6, 0.1);
+ lua_pop(L, 1);
+
+ lua_close(L);
+}
+
+
+void suite_import()
+{
+ lily_run_test(test_push_vector);
+}