From 7f5d38aaf8cf7a067d1dce677b33f8b597f6a974 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 19 Sep 2022 10:37:38 -0500 Subject: add tangents & bitangents --- src/import/import.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-) (limited to 'src/import/import.c') diff --git a/src/import/import.c b/src/import/import.c index a68ac05..73075d4 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -33,20 +33,47 @@ void push_aistring(lua_State *L, struct aiString str) } +/* mesh components: + * DONE: + * mBitangents + * mFaces + * mNormals + * mNumFaces + * mNumVertices + * mTangents + * mVertices + * + * TODO: + * mAnimMeshes + * mBones + * mColors + * mMaterialIndex + * mMethod + * mName + * mNumAnimMeshes + * mNumBones + * mNumUVComponents + * mPrimitiveTypes + * mTextureCoords + * mTextureCoordsNames + */ void push_mesh(lua_State *L, struct aiMesh mesh) { - /* create mesh table */ + /* --=== create mesh table ===-- */ lua_createtable(L, 0, 1); int meshtbl = lua_gettop(L); int count = mesh.mNumVertices; int pop_count = 0; - /* create tables */ + /* --=== create tables ===-- */ + + /* positions */ lua_createtable(L, count, 0); int vertices = lua_gettop(L); pop_count += 1; + /* normals */ int normals = 0; if (mesh.mNormals != NULL) { lua_createtable(L, count, 0); @@ -54,7 +81,19 @@ void push_mesh(lua_State *L, struct aiMesh mesh) pop_count += 1; } - /* populate vertices */ + /* tangents & bitangents */ + int tangents = 0; + int bitangents = 0; + if (mesh.mTangents != NULL) { + lua_createtable(L, count, 0); + tangents = lua_gettop(L); + lua_createtable(L, count, 0); + bitangents = lua_gettop(L); + pop_count += 2; + } + + /* --=== populate vertices ===-- */ + for (int i=0; i